@hackage wai-problem-details0.1.1.0
Problem details middleware for WAI
Categories
License
MIT
Maintainer
goussasalexander@gmail.com
Links
Versions
Installation
Dependencies (9)
- aeson >=2.1.2 && <2.2
- base ^>=4.16.3.0
- 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 Show all…
Dependents (0)
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