License | BSD3 |
---|---|
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
- data Static s
- type Root = Static ""
- data p1 :/ p2
- data Route ms r
- class Router server r pr where
- route :: (iface ~ ApiInterface server) => Proxy r -> server -> ParsedRoute pr -> RoutingApplication
- router :: (iface ~ ApiInterface server, Router server apis `(CUSTOM "", `[]`)`) => Proxy apis -> server -> RoutingApplication
- type family ToPieces r :: [*]
- data PathSegment
- class MkPathFormatString r where
- mkPathFormatString :: Proxy r -> [PathSegment]
Route types
Datatype representing a static path piece.
(KnownSymbol piece, ApiHandler s m (Static piece), ToHeader (HeaderOut m (Static piece)), ToParam (CookieOut m (Static piece)) Cookie, FromParam (QueryParam m (Static piece)) QueryParam, FromParam (FormParam m (Static piece)) FormParam, FromParam (FileParam m (Static piece)) FileParam, FromHeader (HeaderIn m (Static piece)), FromParam (CookieIn m (Static piece)) Cookie, Encodings (ContentTypes m (Static piece)) (ApiOut m (Static piece)), Encodings (ContentTypes m (Static piece)) (ApiErr m (Static piece)), (~) * (PathParam m (Static piece)) (), ParamErrToApiErr (ApiErr m (Static piece)), ToHListRecTuple (StripContents (RequestBody m (Static piece))), PartDecodings (RequestBody m (Static piece)), Typeable * m, Typeable * (Static piece), WebApiImplementation s) => Router * s (Static piece) ((,) * [*] m pp) Source | |
KnownSymbol s => MkPathFormatString (Static s) Source | |
type PathParam' m (Static s) = () Source |
Datatype representing a route.
(KnownSymbol rpiece, (~) [*] paths ((:++) * pp ((:) * (DynamicPiece lpiece) ((:) * (StaticPiece rpiece) ([] *)))), (~) [*] paths ((:++) * ((:++) * pp ((:) * (DynamicPiece lpiece) ([] *))) ((:) * (StaticPiece rpiece) ([] *))), (~) * route (FromPieces paths), ApiHandler s m route, (~) * (PathParam m route) (HListToTuple (FilterDynP paths)), FromParam (QueryParam m route) QueryParam, FromParam (FormParam m route) FormParam, FromParam (FileParam m route) FileParam, FromParam (CookieIn m route) Cookie, FromHeader (HeaderIn m route), Encodings (ContentTypes m route) (ApiErr m route), Encodings (ContentTypes m route) (ApiOut m route), ToHeader (HeaderOut m route), ToParam (CookieOut m route) Cookie, DecodeParam lpiece, ParamErrToApiErr (ApiErr m route), ToHListRecTuple (StripContents (RequestBody m route)), PartDecodings (RequestBody m route), Typeable * m, Typeable * route, WebApiImplementation s) => Router * s ((:/) * Symbol lpiece rpiece) ((,) * [*] m pp) Source | |
(KnownSymbol lpiece, KnownSymbol rpiece, (~) [*] paths ((:++) * pp ((:) * (StaticPiece lpiece) ((:) * (StaticPiece rpiece) ([] *)))), (~) [*] paths ((:++) * ((:++) * pp ((:) * (StaticPiece lpiece) ([] *))) ((:) * (StaticPiece rpiece) ([] *))), (~) * route (FromPieces paths), ApiHandler s m route, (~) * (PathParam m route) (HListToTuple (FilterDynP paths)), FromParam (QueryParam m route) QueryParam, FromParam (FormParam m route) FormParam, FromParam (FileParam m route) FileParam, FromParam (CookieIn m route) Cookie, FromHeader (HeaderIn m route), Encodings (ContentTypes m route) (ApiErr m route), Encodings (ContentTypes m route) (ApiOut m route), ToHeader (HeaderOut m route), ToParam (CookieOut m route) Cookie, ParamErrToApiErr (ApiErr m route), ToHListRecTuple (StripContents (RequestBody m route)), PartDecodings (RequestBody m route), Typeable * m, Typeable * route, WebApiImplementation s) => Router * s ((:/) Symbol Symbol lpiece rpiece) ((,) * [*] m pp) Source | |
(Router * s (MarkDyn rest) ((,) * [*] m ((:++) * pp ((:) * (StaticPiece piece) ([] *)))), KnownSymbol piece) => Router * s ((:/) Symbol * piece rest) ((,) * [*] m pp) Source | |
(Router * s (MarkDyn rest) ((,) * [*] m ((:++) * pp ((:) * (DynamicPiece piece) ([] *)))), DecodeParam piece) => Router * s ((:/) * * piece rest) ((,) * [*] m pp) Source | |
MkFormatStr (ToPieces * ((:/) k k1 a b)) => MkPathFormatString ((:/) k k a b) Source | |
type PathParam' m ((:/) k k1 p1 p2) Source |
Default routing implementation
Datatype representing a endpoint.
class Router server r pr where Source
Class to do the default routing.
route :: (iface ~ ApiInterface server) => Proxy r -> server -> ParsedRoute pr -> RoutingApplication Source
(KnownSymbol piece, ApiHandler s m (Static piece), ToHeader (HeaderOut m (Static piece)), ToParam (CookieOut m (Static piece)) Cookie, FromParam (QueryParam m (Static piece)) QueryParam, FromParam (FormParam m (Static piece)) FormParam, FromParam (FileParam m (Static piece)) FileParam, FromHeader (HeaderIn m (Static piece)), FromParam (CookieIn m (Static piece)) Cookie, Encodings (ContentTypes m (Static piece)) (ApiOut m (Static piece)), Encodings (ContentTypes m (Static piece)) (ApiErr m (Static piece)), (~) * (PathParam m (Static piece)) (), ParamErrToApiErr (ApiErr m (Static piece)), ToHListRecTuple (StripContents (RequestBody m (Static piece))), PartDecodings (RequestBody m (Static piece)), Typeable * m, Typeable * (Static piece), WebApiImplementation s) => Router * s (Static piece) ((,) * [*] m pp) Source | |
Router * s (Route ([] *) r) pr Source | |
(SingMethod m, Router * s r ((,) * [*] m ([] *)), Router * s (Route ms r) pr) => Router * s (Route ((:) * m ms) r) pr Source | |
(KnownSymbol rpiece, (~) [*] paths ((:++) * pp ((:) * (DynamicPiece lpiece) ((:) * (StaticPiece rpiece) ([] *)))), (~) [*] paths ((:++) * ((:++) * pp ((:) * (DynamicPiece lpiece) ([] *))) ((:) * (StaticPiece rpiece) ([] *))), (~) * route (FromPieces paths), ApiHandler s m route, (~) * (PathParam m route) (HListToTuple (FilterDynP paths)), FromParam (QueryParam m route) QueryParam, FromParam (FormParam m route) FormParam, FromParam (FileParam m route) FileParam, FromParam (CookieIn m route) Cookie, FromHeader (HeaderIn m route), Encodings (ContentTypes m route) (ApiErr m route), Encodings (ContentTypes m route) (ApiOut m route), ToHeader (HeaderOut m route), ToParam (CookieOut m route) Cookie, DecodeParam lpiece, ParamErrToApiErr (ApiErr m route), ToHListRecTuple (StripContents (RequestBody m route)), PartDecodings (RequestBody m route), Typeable * m, Typeable * route, WebApiImplementation s) => Router * s ((:/) * Symbol lpiece rpiece) ((,) * [*] m pp) Source | |
(KnownSymbol lpiece, KnownSymbol rpiece, (~) [*] paths ((:++) * pp ((:) * (StaticPiece lpiece) ((:) * (StaticPiece rpiece) ([] *)))), (~) [*] paths ((:++) * ((:++) * pp ((:) * (StaticPiece lpiece) ([] *))) ((:) * (StaticPiece rpiece) ([] *))), (~) * route (FromPieces paths), ApiHandler s m route, (~) * (PathParam m route) (HListToTuple (FilterDynP paths)), FromParam (QueryParam m route) QueryParam, FromParam (FormParam m route) FormParam, FromParam (FileParam m route) FileParam, FromParam (CookieIn m route) Cookie, FromHeader (HeaderIn m route), Encodings (ContentTypes m route) (ApiErr m route), Encodings (ContentTypes m route) (ApiOut m route), ToHeader (HeaderOut m route), ToParam (CookieOut m route) Cookie, ParamErrToApiErr (ApiErr m route), ToHListRecTuple (StripContents (RequestBody m route)), PartDecodings (RequestBody m route), Typeable * m, Typeable * route, WebApiImplementation s) => Router * s ((:/) Symbol Symbol lpiece rpiece) ((,) * [*] m pp) Source | |
(Router * s (MarkDyn rest) ((,) * [*] m ((:++) * pp ((:) * (StaticPiece piece) ([] *)))), KnownSymbol piece) => Router * s ((:/) Symbol * piece rest) ((,) * [*] m pp) Source | |
(Router * s (MarkDyn rest) ((,) * [*] m ((:++) * pp ((:) * (DynamicPiece piece) ([] *)))), DecodeParam piece) => Router * s ((:/) * * piece rest) ((,) * [*] m pp) Source | |
Router [k] s ([] k) pr Source | |
(Router * s route pr, Router [*] s routes pr) => Router [*] s ((:) * route routes) pr Source |
router :: (iface ~ ApiInterface server, Router server apis `(CUSTOM "", `[]`)`) => Proxy apis -> server -> RoutingApplication Source
type family ToPieces r :: [*] Source
Convert the path into a flat hierarchy.
ToPieces (Static s) = `[StaticPiece s]` | |
ToPieces ((p1 :: Symbol) :/ (p2 :: Symbol)) = `[StaticPiece p1, StaticPiece p2]` | |
ToPieces ((p1 :: *) :/ (p2 :: Symbol)) = `[DynamicPiece p1, StaticPiece p2]` | |
ToPieces ((p1 :: Symbol) :/ (p2 :/ p3)) = StaticPiece p1 : ToPieces (p2 :/ p3) | |
ToPieces ((p1 :: *) :/ (p2 :/ p3)) = DynamicPiece p1 : ToPieces (p2 :/ p3) | |
ToPieces ((p1 :: *) :/ (p2 :: *)) = `[DynamicPiece p1, DynamicPiece p2]` | |
ToPieces ((p1 :: Symbol) :/ (p2 :: *)) = `[StaticPiece p1, DynamicPiece p2]` |
Custom routing
data PathSegment Source
Type of segments of a Path.
StaticSegment Text | A static segment |
Hole | A dynamic segment |
class MkPathFormatString r where Source
Describe representation of the route.
mkPathFormatString :: Proxy r -> [PathSegment] Source
Given a route, this function should produce the [PathSegment]
of that route. This gives the flexibility to hook in a different routing system into the application.
KnownSymbol s => MkPathFormatString (Static s) Source | |
MkFormatStr (ToPieces * ((:/) k k1 a b)) => MkPathFormatString ((:/) k k a b) Source |