| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Web.Routing.Combinators
Synopsis
- data PathState
- data Path (as :: [Type]) (pathState :: PathState) where
- Empty :: Path ('[] :: [Type]) 'Open
- StaticCons :: forall (as :: [Type]) (pathState :: PathState). Text -> Path as pathState -> Path as pathState
- VarCons :: forall a (as1 :: [Type]) (pathState :: PathState). (FromHttpApiData a, Typeable a) => Path as1 pathState -> Path (a ': as1) pathState
- Wildcard :: forall (as1 :: [Type]). Path as1 'Open -> Path (Text ': as1) 'Closed
- WithExtension :: forall (as1 :: [Type]) (bs :: [Type]). Path as1 'Open -> Path bs 'Open -> Path (Append as1 bs) 'Open
- AppendPath :: forall (as1 :: [Type]) (bs :: [Type]) (pathState :: PathState). Path as1 'Open -> Path bs pathState -> Path (Append as1 bs) pathState
- toInternalPath :: forall (as :: [Type]) (pathState :: PathState). Path as pathState -> PathInternal as
- type Var a = Path '[a] 'Open
- data AltVar a b
- var :: (Typeable a, FromHttpApiData a) => Path '[a] 'Open
- static :: String -> Path ('[] :: [Type]) 'Open
- root :: Path ('[] :: [Type]) 'Open
- trailingSlash :: forall (as :: [Type]). Path as 'Open -> Path as 'Open
- wildcard :: Path '[Text] 'Closed
- (</>) :: forall (as :: [Type]) (bs :: [Type]) (ps2 :: PathState). Path as 'Open -> Path bs ps2 -> Path (Append as bs) ps2
- (<.>) :: forall (as :: [Type]) (bs :: [Type]). Path as 'Open -> Path bs 'Open -> Path (Append as bs) 'Open
- pathToRep :: forall (as :: [Type]) (ps :: PathState). Path as ps -> Rep as
- appendRep :: forall (as :: [Type]) (bs :: [Type]). Rep as -> Rep bs -> Rep (Append as bs)
- renderRoute :: forall (as :: [Type]). AllHave ToHttpApiData as => Path as 'Open -> HVect as -> Text
- renderRouteWith :: forall (as :: [Type]). AllHave ToHttpApiData as => SlashPolicy -> Path as 'Open -> HVect as -> Text
- normalizePath :: forall (as :: [Type]) (ps :: PathState). SlashPolicy -> Path as ps -> Path as ps
- renderRoute' :: forall (as :: [Type]). AllHave ToHttpApiData as => Path as 'Open -> HVect as -> [Text]
- captureTexts :: forall (as :: [Type]). AllHave ToHttpApiData as => HVect as -> [Text]
- renderPieces :: forall (as :: [Type]). Path as 'Open -> [Text] -> ([Text], [Text])
- joinWithDot :: [Text] -> [Text] -> [Text]
- renderRouteEncoded :: forall (as :: [Type]). AllHave ToHttpApiData as => Path as 'Open -> HVect as -> Text
- renderRouteEncodedWith :: forall (as :: [Type]). AllHave ToHttpApiData as => SlashPolicy -> Path as 'Open -> HVect as -> Text
Documentation
data Path (as :: [Type]) (pathState :: PathState) where Source #
Constructors
| Empty :: Path ('[] :: [Type]) 'Open | |
| StaticCons :: forall (as :: [Type]) (pathState :: PathState). Text -> Path as pathState -> Path as pathState | |
| VarCons :: forall a (as1 :: [Type]) (pathState :: PathState). (FromHttpApiData a, Typeable a) => Path as1 pathState -> Path (a ': as1) pathState | |
| Wildcard :: forall (as1 :: [Type]). Path as1 'Open -> Path (Text ': as1) 'Closed | |
| WithExtension :: forall (as1 :: [Type]) (bs :: [Type]). Path as1 'Open -> Path bs 'Open -> Path (Append as1 bs) 'Open | |
| AppendPath :: forall (as1 :: [Type]) (bs :: [Type]) (pathState :: PathState). Path as1 'Open -> Path bs pathState -> Path (Append as1 bs) pathState |
toInternalPath :: forall (as :: [Type]) (pathState :: PathState). Path as pathState -> PathInternal as Source #
A variant of Either with a FromHttpApiData definition that tries both branches without a prefix.
Useful to define routes with vars that should work with different types.
Instances
| (Eq a, Eq b) => Eq (AltVar a b) Source # | |
| (Ord a, Ord b) => Ord (AltVar a b) Source # | |
| (Read a, Read b) => Read (AltVar a b) Source # | |
| (Show a, Show b) => Show (AltVar a b) Source # | |
| (FromHttpApiData a, FromHttpApiData b) => FromHttpApiData (AltVar a b) Source # | |
static :: String -> Path ('[] :: [Type]) 'Open Source #
A static route piece. One leading slash is optional. Empty internal and
trailing pieces are retained for strict routing; compatibility routing and
renderRoute ignore them. Use renderRouteWith with the application's policy.
root :: Path ('[] :: [Type]) 'Open Source #
The root of a path piece. Use to define a handler for "/"
trailingSlash :: forall (as :: [Type]). Path as 'Open -> Path as 'Open Source #
Require a trailing slash in strict routing, including after a capture. Root remains root, and a path already ending in a slash is unchanged.
wildcard :: Path '[Text] 'Closed Source #
Matches the rest of the route. Should be the last part of the path.
(</>) :: forall (as :: [Type]) (bs :: [Type]) (ps2 :: PathState). Path as 'Open -> Path bs ps2 -> Path (Append as bs) ps2 Source #
(<.>) :: forall (as :: [Type]) (bs :: [Type]). Path as 'Open -> Path bs 'Open -> Path (Append as bs) 'Open infixl 8 Source #
Join the last segment on the left and the first on the right with a dot.
Both sides may contain typed captures: var . "txt" or var . var.
Matching tries the rightmost dot first and accepts the first split whose
typed parsers and literals succeed. Use a custom capture type to restrict
extensions; a Text capture accepts any text, including an empty extension.
Static routes take precedence over extensions, then plain captures and
wildcards. More literal characters give an extension pattern priority.
renderRoute :: forall (as :: [Type]). AllHave ToHttpApiData as => Path as 'Open -> HVect as -> Text Source #
renderRouteWith :: forall (as :: [Type]). AllHave ToHttpApiData as => SlashPolicy -> Path as 'Open -> HVect as -> Text Source #
Render with the same empty-segment policy used by the registry. Values are
URL pieces, as with renderRoute; this function does not percent-encode them.
normalizePath :: forall (as :: [Type]) (ps :: PathState). SlashPolicy -> Path as ps -> Path as ps Source #
renderRoute' :: forall (as :: [Type]). AllHave ToHttpApiData as => Path as 'Open -> HVect as -> [Text] Source #
captureTexts :: forall (as :: [Type]). AllHave ToHttpApiData as => HVect as -> [Text] Source #
renderRouteEncoded :: forall (as :: [Type]). AllHave ToHttpApiData as => Path as 'Open -> HVect as -> Text Source #
Percent-encode each complete segment after joining extension pieces.
This protects slashes, spaces, percent signs, query delimiters and Unicode
in captures. The unencoded renderRoute remains available for compatibility.
renderRouteEncodedWith :: forall (as :: [Type]). AllHave ToHttpApiData as => SlashPolicy -> Path as 'Open -> HVect as -> Text Source #