| Copyright | (c) Frederick Pringle 2025 |
|---|---|
| License | BSD-3-Clause |
| Maintainer | freddyjepringle@gmail.com |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Servant.API.Routes.Route
Contents
Description
Simple term-level representation of Servant API endpoints.
Synopsis
- data Route
- defRoute :: Method -> Route
- renderRoute :: Route -> Text
- routeMethod :: Lens' Route Method
- routePath :: Lens' Route Path
- routeParams :: Lens' Route (Set Param)
- routeRequestHeaders :: Lens' Route (Set HeaderRep)
- routeRequestBody :: Lens' Route Request
- routeResponse :: Lens' Route Responses
- routeAuths :: Lens' Route (Set Auth)
- add :: Ord a => ASetter s t (Set a) (Set a) -> a -> s -> t
API routes
The Route type is not sophisticated, and its internals are hidden.
Create Routes using defRoute, and update its fields
using the provided lenses.
A simple representation of a single endpoint of an API.
renderRoute :: Route -> Text Source #
Pretty-print a Route. Note that the output is minimal and doesn't contain all the information
contained in a Route. For full output, use the ToJSON instance.
ghci> renderRoute $ defRoute \"POST\"
"POST /"
ghci> :{
ghci| renderRoute $
ghci| defRoute \"POST\"
ghci| & routePath %~ prependPathPart "api/v2"
ghci| & routeParams .~ [singleParam @"p1" @T.Text, flagParam @"flag", arrayElemParam @"p2s" @(Maybe Int)]
ghci| :}
"POST /api/v2?p1=<Text>&flag&p2s=<[Maybe Int]>"