Portability | non-portable (uses ghc extensions) |
---|---|
Stability | experimental |
Maintainer | ajnsit@gmail.com |
This package provides typesafe URLs for Wai applications.
- parseRoutes :: QuasiQuoter
- parseRoutesFile :: FilePath -> Q Exp
- parseRoutesNoCheck :: QuasiQuoter
- parseRoutesFileNoCheck :: FilePath -> Q Exp
- mkRoute :: String -> [Resource] -> Q [Dec]
- dispatch :: Route route => route -> Middleware
- data Resource = Resource String [Piece] [String]
- data Piece
- class Route route where
- showRoute :: route -> [Text]
- readRoute :: [Text] -> Either String route
- dispatchRoute :: route -> String -> Maybe Application
Documentation
parseRoutes :: QuasiQuoterSource
A quasi-quoter to parse a string into a list of Resource
s. Checks for
overlapping routes, failing if present; use parseRoutesNoCheck
to skip the
checking
parseRoutesFile :: FilePath -> Q ExpSource
A quasi-quoter to parse the contents of a file into a list of Resource
s. Checks for
overlapping routes, failing if present; use parseRoutesFileNoCheck
to skip the
checking
parseRoutesNoCheck :: QuasiQuoterSource
Same as parseRoutes
, but performs no overlap checking.
parseRoutesFileNoCheck :: FilePath -> Q ExpSource
Same as parseRoutesFile
, but performs no overlap checking.
mkRoute :: String -> [Resource] -> Q [Dec]Source
Call this function to automatically generate your route datatype and Route
instance
dispatch :: Route route => route -> MiddlewareSource
The application dispatcher function.
This function takes an instance of Route
class as an argument.
It is normal to pass (undefined::YourRoute).
A single resource pattern.
First argument is the name of the constructor, second is the URL pattern to match, third is how to dispatch.
A single piece of a URL, delimited by slashes.
In the case of StaticPiece, the argument is the value of the piece; for the other constructors, it is the name of the parameter represented by this piece.