| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
IHP.Router.IHP
Contents
Description
The ihp-router package ships an IHP-free [routes|…|] quasi-quoter
that emits HasPath instances and a parameterised
<ctrlLower>Trie :: (Ctrl -> Application) -> RouteTrie binding per
controller. Plain WAI users wire that binding into
routeTrieMiddleware with their own dispatch
function.
This module is the IHP-specific shim that composes on top:
routes/routesDec— IHP-flavoured quoter. Emits everythinggenericEmitproduces, plus aCanRouteinstance per controller (whosetoControllerRoutewraps<ctrlLower>Trie runAction'in aControllerRouteTrie) and, for lowercase-header blocks, awebRoutes :: [ControllerRoute app]binding ready forFrontController.controllers.- 'instance UrlCapture (Id' table)' — IHP's primary-key-driven
capture. Lives here (not in
ihp-router) because it needsPrimaryKey.
User code accesses the IHP-flavoured quoter as
import IHP.Router.DSL (routes), which re-exports from this module.
The user-visible import surface is unchanged from before the
extraction.
Synopsis
- routes :: QuasiQuoter
- routesDec :: String -> Q [Dec]
- ihpRoutesDec :: String -> Q [Dec]
- ihpEmit :: ParsedBlock -> Q [Dec]
Documentation
routes :: QuasiQuoter Source #
The IHP-flavoured [routes|…|] quasi-quoter. Behaves identically
to the pre-extraction quoter — re-exports the same routesDec that
composes genericEmit with the IHP-specific ihpEmit.
Use as a top-level declaration in Web/Routes.hs:
[routes|webRoutes
GET /Posts PostsAction
GET /ShowPost?postId ShowPostAction
|]
instance FrontController WebApplication where
controllers = webRoutesroutesDec :: String -> Q [Dec] Source #
Underlying TH function for the IHP-flavoured routes quoter.
Composes genericEmit (HasPath + per-controller <ctrlLower>Trie
bindings) with ihpEmit (IHP CanRoute instance + lowercase-header
binding).
ihpRoutesDec :: String -> Q [Dec] Source #
Alias for routesDec. Exposed so callers that already use the
generic genericRoutesDec have a matching named
entry point on the IHP-flavoured side.
ihpEmit :: ParsedBlock -> Q [Dec] Source #
Emit the IHP-flavoured declarations on top of whatever genericEmit
produces:
- one
instance CanRoute Ctrlper controller, whosetoControllerRoutewraps<ctrlLower>Trie runAction'in aControllerRouteTrie; - for a lowercase-header block: a top-level
webRoutes :: [ControllerRoute app]binding that includeswebSocketRoute @T "/path"entries for eachWSroute in the block alongside the regularparseRoute @Ctrlentries.
Orphan instances
| (Typeable table, Typeable (PrimaryKey table), UrlCapture (PrimaryKey table)) => UrlCapture (Id' table) Source # | Captures for IHP Lives in the IHP shim so that |