wai-problem-details: Problem details middleware for WAI

[ library, mit, web ] [ Propose Tags ] [ Report a vulnerability ]

Problem details middleware for WAI.

It exposes a functions to throw exceptions of type ProblemDetailsException that implements the problem details RFC as specified in https://www.rfc-editor.org/rfc/rfc7807.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

  • No current members of group

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1.0
Dependencies aeson (>=2.1.2 && <2.2), base (>=4.16.3.0 && <4.17), bytestring (>=0.11.3 && <0.12), data-default (>=0.7.1 && <0.8), deriving-aeson (>=0.2.9 && <0.3), http-types (>=0.12.3 && <0.13), network-uri (>=2.6.4 && <2.7), text (>=1.2.5 && <1.3), wai (>=3.2.3 && <3.3) [details]
License MIT
Copyright Alexander Goussas 2023
Author Alexander Goussas
Maintainer goussasalexander@gmail.com
Category Web
Home page https://github.com/aloussase/wai-problem-details
Bug tracker https://github.com/aloussase/wai-problem-details/issues
Source repo head: git clone https://github.com/aloussase/wai-problem-details.git
Uploaded by aloussase at 2023-04-28T20:26:22Z
Distributions
Downloads 113 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-04-28 [all 1 reports]

Readme for wai-problem-details-0.1.1.0

[back to package description]

wai-problem-details

Middleware for returning problem details responses as specified in https://www.rfc-editor.org/rfc/rfc7807.

{-# LANGUAGE OverloadedStrings #-}

import qualified Web.Scotty as S
import Network.Wai.Handler.Warp (run)
import Data.Function ((&))
import Data.Default
import Network.Wai.Middleware.ProblemDetails

app :: IO Application
app = S.scottyApp $ do
  S.get "/default"           $ throwProblemDetails def
  S.get "/predefined"        $ throwProblemDetails problemDetails400
  S.get "/predefined-custom" $ throwProblemDetails (problemDetails404 & setTitle "Ahooy!")

main :: IO ()
main = run 8080 =<< app

License

MIT