wai-extra-3.0.2.1: Provides some basic WAI handlers and middleware.

Safe HaskellNone

Network.Wai.UrlMap

Description

This module gives you a way to mount applications under sub-URIs. For example:

 bugsApp, helpdeskApp, apiV1, apiV2, mainApp :: Application

 myApp :: Application
 myApp = mapUrls $
       mount "bugs"     bugsApp
   <|> mount "helpdesk" helpdeskApp
   <|> mount "api"
           (   mount "v1" apiV1
           <|> mount "v2" apiV2
           )
   <|> mountRoot mainApp

Synopsis

Documentation

mount' :: ToApplication a => Path -> a -> UrlMapSource

Mount an application under a given path. The ToApplication typeclass gives you the option to pass either an Application or an UrlMap as the second argument.

mount :: ToApplication a => Text -> a -> UrlMapSource

A convenience function like mount', but for mounting things under a single path segment.

mountRoot :: ToApplication a => a -> UrlMapSource

Mount something at the root. Use this for the last application in the block, to avoid 500 errors from none of the applications matching.