Servant (framework)

The servant library makes it possible to define HTTP APIs on the type level. Then having such API-types one can define clients and servers and even generate automatically mocks and API specs (OpenAPI/Swagger).

Ecosystem

Cookbook

Redirect

type FormPost = ... :> Verb 'POST 303 '[PlainText] (Redirect Text)
type Redirect = Headers '[Header "Location" Link]

-- ...
post :: ... -> Handler (Redirect Text)
post ... = do
  -- ...
  pure $ addHeader (safeLink ...) "ok"