reroute
Safe HaskellNone
LanguageHaskell2010

Web.Routing.Combinators

Synopsis

Documentation

data PathState Source #

Constructors

Open 
Closed 

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 

Instances

Instances details
(a ~ ('[] :: [Type]), pathState ~ 'Open) => IsString (Path a pathState) Source # 
Instance details

Defined in Web.Routing.Combinators

Methods

fromString :: String -> Path a pathState

toInternalPath :: forall (as :: [Type]) (pathState :: PathState). Path as pathState -> PathInternal as Source #

type Var a = Path '[a] 'Open Source #

data AltVar a b 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.

Constructors

AvLeft a 
AvRight b 

Instances

Instances details
(Eq a, Eq b) => Eq (AltVar a b) Source # 
Instance details

Defined in Web.Routing.Combinators

Methods

(==) :: AltVar a b -> AltVar a b -> Bool

(/=) :: AltVar a b -> AltVar a b -> Bool

(Ord a, Ord b) => Ord (AltVar a b) Source # 
Instance details

Defined in Web.Routing.Combinators

Methods

compare :: AltVar a b -> AltVar a b -> Ordering

(<) :: AltVar a b -> AltVar a b -> Bool

(<=) :: AltVar a b -> AltVar a b -> Bool

(>) :: AltVar a b -> AltVar a b -> Bool

(>=) :: AltVar a b -> AltVar a b -> Bool

max :: AltVar a b -> AltVar a b -> AltVar a b

min :: AltVar a b -> AltVar a b -> AltVar a b

(Read a, Read b) => Read (AltVar a b) Source # 
Instance details

Defined in Web.Routing.Combinators

Methods

readsPrec :: Int -> ReadS (AltVar a b)

readList :: ReadS [AltVar a b]

readPrec :: ReadPrec (AltVar a b)

readListPrec :: ReadPrec [AltVar a b]

(Show a, Show b) => Show (AltVar a b) Source # 
Instance details

Defined in Web.Routing.Combinators

Methods

showsPrec :: Int -> AltVar a b -> ShowS

show :: AltVar a b -> String

showList :: [AltVar a b] -> ShowS

(FromHttpApiData a, FromHttpApiData b) => FromHttpApiData (AltVar a b) Source # 
Instance details

Defined in Web.Routing.Combinators

Methods

parseUrlPiece :: Text -> Either Text (AltVar a b)

parseHeader :: ByteString -> Either Text (AltVar a b)

parseQueryParam :: Text -> Either Text (AltVar a b)

var :: (Typeable a, FromHttpApiData a) => Path '[a] 'Open Source #

A route parameter

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.

pathToRep :: forall (as :: [Type]) (ps :: PathState). Path as ps -> Rep as Source #

appendRep :: forall (as :: [Type]) (bs :: [Type]). Rep as -> Rep bs -> Rep (Append as bs) Source #

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 #

renderPieces :: forall (as :: [Type]). Path as 'Open -> [Text] -> ([Text], [Text]) Source #

joinWithDot :: [Text] -> [Text] -> [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.