servant-routes-0.1.0.0: Generate route descriptions from Servant APIs
Copyright(c) Frederick Pringle 2025
LicenseBSD-3-Clause
Maintainerfreddyjepringle@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Servant.API.Routes.Route

Description

Simple term-level representation of Servant API endpoints.

Synopsis

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.

data Route Source #

A simple representation of a single endpoint of an API.

defRoute :: Method -> Route Source #

Given a REST Method, create a default Route: root path ("/") with no params, headers, body, auths, or response.

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]>"

Optics

add :: Ord a => ASetter s t (Set a) (Set a) -> a -> s -> t Source #