servant-errors 0.1.0.3 → 0.1.1.0
raw patch · 5 files changed
+59/−36 lines, 5 filesdep ~aesondep ~basedep ~bytestringPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, base, bytestring, http-api-data, http-media, http-types, scientific, servant, servant-server, string-conversions, text, unordered-containers, wai, warp
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- README.lhs +12/−4
- README.md +12/−4
- servant-errors.cabal +30/−28
- src/Network/Wai/Middleware/Servant/Errors.hs +1/−0
CHANGELOG.md view
@@ -16,3 +16,7 @@ [1]: https://pvp.haskell.org [2]: https://github.com/epicallan/servant-errors/releases++## 0.1.1.0++* support more GHC versions (8.2 - 8.6)
README.lhs view
@@ -55,7 +55,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE DerivingVia #-} module Main where @@ -92,11 +91,20 @@ ---------------------------------------------------------------------------------------- -- | We need a newtype like data type to avoid orphan instances, 'Ctyp' satisfy's that--- We also make use of deriving via to get an Accept instance easily.--- Note: 'HasErrorBody' instance requires an Accept instance for a content-type+-- Also note that 'HasErrorBody' instance requires an Accept instance for a content-type data Ctyp a- deriving Accept via JSON++{-+ if you are using GHC 8.6 and above you can make use of deriving Via+ for creating the Accept Instance++ >> data Ctyp a+ >> deriving Accept via JSON+-}++instance Accept (Ctyp JSON) where+ contentType _ = contentType (Proxy @JSON) instance HasErrorBody (Ctyp JSON) '[] where encodeError = undefined -- write your custom implementation
README.md view
@@ -55,7 +55,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE DerivingVia #-} module Main where @@ -92,11 +91,20 @@ ---------------------------------------------------------------------------------------- -- | We need a newtype like data type to avoid orphan instances, 'Ctyp' satisfy's that--- We also make use of deriving via to get an Accept instance easily.--- Note: 'HasErrorBody' instance requires an Accept instance for a content-type+-- Also note that 'HasErrorBody' instance requires an Accept instance for a content-type data Ctyp a- deriving Accept via JSON++{-+ if you are using GHC 8.6 and above you can make use of deriving Via+ for creating the Accept Instance++ >> data Ctyp a+ >> deriving Accept via JSON+-}++instance Accept (Ctyp JSON) where+ contentType _ = contentType (Proxy @JSON) instance HasErrorBody (Ctyp JSON) '[] where encodeError = undefined -- write your custom implementation
servant-errors.cabal view
@@ -1,6 +1,6 @@-cabal-version: 2.0+cabal-version: 2.4 name: servant-errors-version: 0.1.0.3+version: 0.1.1.0 synopsis: Servant Errors wai-middlware description: A Wai middleware that uniformly structures errors with in a servant application. The library assumes all HTTP responses with status code greater than 200 and without an HTTP content type are error responses. This assumption is derived from servant server error handling implementation. @@ -15,27 +15,20 @@ build-type: Simple extra-doc-files: README.md , CHANGELOG.md-tested-with: GHC == 8.6.4+tested-with: GHC == 8.2.2+ , GHC == 8.4.4+ , GHC == 8.6.5 + source-repository head type: git location: https://github.com/epicallan/servant-errors.git-library- hs-source-dirs: src- exposed-modules: Network.Wai.Middleware.Servant.Errors - build-depends: base ^>= 4.12- , aeson ^>= 1.3- , bytestring ^>= 0.10.8.2- , http-types ^>= 0.12- , http-api-data ^>= 0.3- , http-media ^>= 0.7- , scientific ^>= 0.3- , servant ^>= 0.14- , string-conversions ^>= 0.4- , text ^>= 1.2- , unordered-containers ^>= 0.2- , wai ^>= 3.2+common common-options+ build-depends: base >= 4.10.0.0 && < 4.13+ , aeson >= 1.3+ , text >= 1.2+ , wai >= 3.2 ghc-options: -Wall -Wincomplete-uni-patterns@@ -44,21 +37,30 @@ -Widentities -Wredundant-constraints -fhide-source-paths+ -freverse-errors -Wpartial-fields- default-language: Haskell2010 +library+ import: common-options+ hs-source-dirs: src+ exposed-modules: Network.Wai.Middleware.Servant.Errors+ build-depends: bytestring >= 0.10.8.2+ , http-types >= 0.12+ , http-api-data >= 0.3+ , http-media >= 0.7+ , scientific >= 0.3+ , servant >= 0.13+ , string-conversions >= 0.4+ , unordered-containers >= 0.2+ test-suite readme- build-depends: base- , aeson ^>= 1.3- , text ^>= 1.2- , servant-errors- , servant-server ^>= 0.14- , wai ^>= 3.2- , warp ^>= 3.2.26+ import: common-options+ build-depends: servant-errors+ , servant-server >= 0.13+ , warp >= 3.2.26 main-is: README.lhs type: exitcode-stdio-1.0- default-language: Haskell2010- ghc-options: -pgmL markdown-unlit -Wall+ ghc-options: -pgmL markdown-unlit build-tool-depends: markdown-unlit:markdown-unlit
src/Network/Wai/Middleware/Servant/Errors.hs view
@@ -62,6 +62,7 @@ import Data.IORef (modifyIORef', newIORef, readIORef) import Data.Kind (Type) import Data.List (find)+import Data.Monoid ((<>)) import Data.Proxy (Proxy (..)) import Data.Scientific (Scientific) import Data.String.Conversions (cs)