Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data RouterState = RouterState {}
- class Monad m => HasRouter m where
- type URL m
- getRouterState :: m RouterState
- initRouter :: Text -> SnapletInit b RouterState
- urlPath :: (HasRouter m, PathInfo (URL m)) => URL m -> m Path
- urlPathParams :: (HasRouter m, PathInfo (URL m)) => URL m -> [(Text, Maybe Text)] -> m Path
- redirectURL :: (HasRouter m, MonadSnap m, PathInfo (URL m)) => URL m -> m ()
- redirectURLParams :: (HasRouter m, MonadSnap m, PathInfo (URL m)) => URL m -> [(Text, Maybe Text)] -> m ()
- routeWith :: (PathInfo url, MonadSnap m) => (url -> m ()) -> m ()
- routeWithDebug :: (PathInfo url, MonadSnap m) => (url -> m ()) -> m ()
- urlSplice :: (HasRouter m, PathInfo (URL m)) => URL m -> m [Node]
- urlParamsSplice :: (HasRouter m, PathInfo (URL m)) => URL m -> [(Text, Maybe Text)] -> m [Node]
Documentation
data RouterState Source
class Monad m => HasRouter m where Source
Instantiate this type class for Handler App App
and Handler b
RouterState
so that the snaplet can find its state. An instance requires
a type for URL m
- being the URL data type you have defined - and an
instance of getRouterState
. Assuming your URL data type is called
AppUrl
, the instance for Handler b RouterState
would be
instance HasRouter (Handler b RouterState) where type URL (Handler b RouterState) = AppUrl getRouterState = get
If the lens for the Router snaplet is router
, your Handler App App
instance would be
instance HasRouter (Handler App App) where type URL (Handler App App) = AppUrl getRouterState = with router get
Returns the path for the given URL
:: (HasRouter m, PathInfo (URL m)) | |
=> URL m | URL data type |
-> [(Text, Maybe Text)] | Params |
-> m Path | Path of route with params as query string |
Returns the path with query string for the given URL and params
Redirect to the path for the given URL
:: (HasRouter m, MonadSnap m, PathInfo (URL m)) | |
=> URL m | URL data type |
-> [(Text, Maybe Text)] | Params |
-> m () |
Redirect to the path for the given URL with params as query string
Given a routing function, routes matching requests or calls
pass
.
Given a routing function, routes matching requests or returns debugging information. This is not suitable for production, but can be useful in seeing what paths are available or determining why a path isn't routing as expected.
Returns the given URL as a Heist
splice