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

Safe Haskell | Safe-Inferred
Language | Haskell2010

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

- data UrlMap' a
- type UrlMap = UrlMap' Application
- mount' :: ToApplication a => Path -> a -> UrlMap
- mount :: ToApplication a => Text -> a -> UrlMap
- mountRoot :: ToApplication a => a -> UrlMap
- mapUrls :: UrlMap -> Application

# Documentation

data UrlMap' a Source #

#### Instances

Instances details

Alternative UrlMap' Source # |
Instance details Defined in Network.Wai.UrlMap Methods empty :: UrlMap' a Source # (<|>) :: UrlMap' a -> UrlMap' a -> UrlMap' a Source # some :: UrlMap' a -> UrlMap' [a] Source # many :: UrlMap' a -> UrlMap' [a] Source #
Applicative UrlMap' Source # |
Instance details Defined in Network.Wai.UrlMap Methods pure :: a -> UrlMap' a Source # (<*>) :: UrlMap' (a -> b) -> UrlMap' a -> UrlMap' b Source # liftA2 :: (a -> b -> c) -> UrlMap' a -> UrlMap' b -> UrlMap' c Source # (*>) :: UrlMap' a -> UrlMap' b -> UrlMap' b Source # (<*) :: UrlMap' a -> UrlMap' b -> UrlMap' a Source #
Functor UrlMap' Source # |
Instance details Defined in Network.Wai.UrlMap Methods fmap :: (a -> b) -> UrlMap' a -> UrlMap' b Source # (<$) :: a -> UrlMap' b -> UrlMap' a Source #

type UrlMap = UrlMap' Application Source #

mount' :: ToApplication a => Path -> a -> UrlMap Source #

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 -> UrlMap Source #

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

mountRoot :: ToApplication a => a -> UrlMap Source #

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

mapUrls :: UrlMap -> Application Source #