servant-routes-0.1.0.0: Generate route descriptions from Servant APIs
Copyright(c) Frederick Pringle 2024
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

data Route Source #

A simple representation of a single endpoint of an API.

The Route type is not sophisticated, and its internals are hidden. Create Routes using defRoute, and update its fields using the provided lenses.

Instances

Instances details
ToJSON Route Source # 
Instance details

Defined in Servant.API.Routes.Route

Show Route Source # 
Instance details

Defined in Servant.API.Routes.Route

Eq Route Source # 
Instance details

Defined in Servant.API.Routes.Route

Methods

(==) :: Route -> Route -> Bool Source #

(/=) :: Route -> Route -> Bool Source #

Ord Route Source # 
Instance details

Defined in Servant.API.Routes.Route

defRoute :: Method -> Route Source #

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

showRoute :: 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> showRoute $ defRoute \"POST\"
"POST /"
ghci> :{
ghci| showRoute $
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