Safe Haskell | None |
---|---|
Language | Haskell98 |
Web.Routes.Site
- data Site url a = Site {
- handleSite :: (url -> [(Text, Maybe Text)] -> Text) -> url -> a
- formatPathSegments :: url -> ([Text], [(Text, Maybe Text)])
- parsePathSegments :: [Text] -> Either String url
- setDefault :: url -> Site url a -> Site url a
- runSite :: Text -> Site url a -> [Text] -> Either String a
Documentation
A site groups together the three functions necesary to make an application:
- A function to convert from the URL type to path segments.
- A function to convert from path segments to the URL, if possible.
- A function to return the application for a given URL.
There are two type parameters for Site: the first is the URL datatype, the second is the application datatype. The application datatype will depend upon your server backend.
Constructors
Site | |
Fields
|
setDefault :: url -> Site url a -> Site url a Source #
Override the "default" URL, ie the result of parsePathSegments
[].
Arguments
:: Text | application root, with trailing slash |
-> Site url a | |
-> [Text] | path info, (call |
-> Either String a |
Retrieve the application to handle a given request.
NOTE: use decodePathInfo
to convert a ByteString
url to a properly decoded list of path segments