packages feed

servant 0.18.2 → 0.18.3

raw patch · 10 files changed

+69/−22 lines, 10 filesdep ~attoparsecdep ~basedep ~bytestring

Dependency ranges changed: attoparsec, base, bytestring, http-api-data, singleton-bool

Files

CHANGELOG.md view
@@ -1,5 +1,18 @@ [The latest version of this document is on GitHub.](https://github.com/haskell-servant/servant/blob/master/servant/CHANGELOG.md) +0.18.3+------++### Significant changes++- Add response header support to UVerb (#1420).+- Use Capture Description if available (#1423).++### Other changes++- Support GHC-9.0.1.+- Bump `bytestring`, `attoparsec`, `hspec` and `singleton-bool` dependencies.+ 0.18.2 ------ 
servant.cabal view
@@ -1,6 +1,6 @@ cabal-version:       >=1.10 name:                servant-version:             0.18.2+version:             0.18.3  synopsis:            A family of combinators for defining webservices APIs category:            Servant, Web@@ -20,7 +20,7 @@ copyright:           2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors build-type:          Simple -tested-with: GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.2+tested-with: GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.2 || ==9.0.1            , GHCJS == 8.4  extra-source-files:@@ -78,8 +78,8 @@   --   -- note: mtl lower bound is so low because of GHC-7.8   build-depends:-      base                   >= 4.9      && < 4.15-    , bytestring             >= 0.10.8.1 && < 0.11+      base                   >= 4.9      && < 4.16+    , bytestring             >= 0.10.8.1 && < 0.12     , mtl                    >= 2.2.2    && < 2.3     , sop-core               >= 0.4.0.0  && < 0.6     , transformers           >= 0.5.2.0  && < 0.6@@ -89,15 +89,15 @@   -- We depend (heavily) on the API of these packages:   -- i.e. re-export, or allow using without direct dependency   build-depends:-      http-api-data          >= 0.4.1    && < 0.4.3-    , singleton-bool         >= 0.1.4    && < 0.1.6+      http-api-data          >= 0.4.1    && < 0.4.4+    , singleton-bool         >= 0.1.4    && < 0.1.7    -- Other dependencies: Lower bound around what is in the latest Stackage LTS.   -- Here can be exceptions if we really need features from the newer versions.   build-depends:       base-compat            >= 0.10.5   && < 0.12     , aeson                  >= 1.4.1.0  && < 1.6-    , attoparsec             >= 0.13.2.2 && < 0.14+    , attoparsec             >= 0.13.2.2 && < 0.15     , bifunctors             >= 5.5.3    && < 5.6     , case-insensitive       >= 1.2.0.11 && < 1.3     , deepseq                >= 1.4.2.0  && < 1.5@@ -163,9 +163,9 @@    -- Additional dependencies   build-depends:-      hspec                >= 2.6.0    && < 2.8+      hspec                >= 2.6.0    && < 2.9     , QuickCheck           >= 2.12.6.1 && < 2.15     , quickcheck-instances >= 0.3.19   && < 0.4    build-tool-depends:-    hspec-discover:hspec-discover >= 2.6.0 && < 2.8+    hspec-discover:hspec-discover >= 2.6.0 && < 2.9
src/Servant/API/ContentTypes.hs view
@@ -20,7 +20,7 @@ -- -- Content-Types are used in `ReqBody` and the method combinators: ----- >>> type MyEndpoint = ReqBody '[JSON, PlainText] Book :> Get '[JSON, PlainText] Book+-- >>> type MyEndpoint = ReqBody '[JSON, PlainText] Book :> Put '[JSON, PlainText] Book -- -- Meaning the endpoint accepts requests of Content-Type @application/json@ -- or @text/plain;charset-utf8@, and returns data in either one of those
src/Servant/API/ResponseHeaders.hs view
@@ -51,6 +51,9 @@  import           Prelude () import           Prelude.Compat+import           Servant.API.ContentTypes+                 (JSON, PlainText, FormUrlEncoded, OctetStream,+                  MimeRender(..)) import           Servant.API.Header                  (Header) 
src/Servant/API/UVerb.hs view
@@ -36,7 +36,7 @@ import Data.Proxy (Proxy (Proxy)) import GHC.TypeLits (Nat) import Network.HTTP.Types (Status, StdMethod)-import Servant.API.ContentTypes (NoContent, MimeRender(mimeRender), MimeUnrender(mimeUnrender))+import Servant.API.ContentTypes (JSON, PlainText, FormUrlEncoded, OctetStream, NoContent, MimeRender(mimeRender), MimeUnrender(mimeUnrender)) import Servant.API.Status (KnownStatus, statusVal) import Servant.API.UVerb.Union @@ -69,13 +69,6 @@ newtype WithStatus (k :: Nat) a = WithStatus a   deriving (Eq, Show) -instance MimeRender ctype a => MimeRender ctype (WithStatus _status a) where-  mimeRender contentTypeProxy (WithStatus a) = mimeRender contentTypeProxy a--instance MimeUnrender ctype a => MimeUnrender ctype (WithStatus _status a) where-  mimeUnrender contentTypeProxy input =-    WithStatus <$> mimeUnrender contentTypeProxy input- -- | an instance of this typeclass assigns a HTTP status code to a return type -- -- Example:@@ -105,3 +98,27 @@ -- Backwards compatibility is tricky, though: this type alias would mean people would have to -- use 'respond' instead of 'pure' or 'return', so all old handlers would have to be rewritten. data UVerb (method :: StdMethod) (contentTypes :: [*]) (as :: [*])++instance {-# OVERLAPPING #-} MimeRender JSON a => MimeRender JSON (WithStatus _status a) where+  mimeRender contentTypeProxy (WithStatus a) = mimeRender contentTypeProxy a++instance {-# OVERLAPPING #-} MimeRender PlainText a => MimeRender PlainText (WithStatus _status a) where+  mimeRender contentTypeProxy (WithStatus a) = mimeRender contentTypeProxy a++instance {-# OVERLAPPING #-} MimeRender FormUrlEncoded a => MimeRender FormUrlEncoded (WithStatus _status a) where+  mimeRender contentTypeProxy (WithStatus a) = mimeRender contentTypeProxy a++instance {-# OVERLAPPING #-} MimeRender OctetStream a => MimeRender OctetStream (WithStatus _status a) where+  mimeRender contentTypeProxy (WithStatus a) = mimeRender contentTypeProxy a++instance {-# OVERLAPPING #-} MimeUnrender JSON a => MimeUnrender JSON (WithStatus _status a) where+  mimeUnrender contentTypeProxy input = WithStatus <$> mimeUnrender contentTypeProxy input++instance {-# OVERLAPPING #-} MimeUnrender PlainText a => MimeUnrender PlainText (WithStatus _status a) where+  mimeUnrender contentTypeProxy input = WithStatus <$> mimeUnrender contentTypeProxy input++instance {-# OVERLAPPING #-} MimeUnrender FormUrlEncoded a => MimeUnrender FormUrlEncoded (WithStatus _status a) where+  mimeUnrender contentTypeProxy input = WithStatus <$> mimeUnrender contentTypeProxy input++instance {-# OVERLAPPING #-} MimeUnrender OctetStream a => MimeUnrender OctetStream (WithStatus _status a) where+  mimeUnrender contentTypeProxy input = WithStatus <$> mimeUnrender contentTypeProxy input
src/Servant/API/UVerb/Union.hs view
@@ -47,7 +47,7 @@ -}  -- | Type-level code for implementing and using 'UVerb'.  Heavily inspired by--- [world-piece](https://github.com/cdepillabout/world-peace).+-- [world-peace](https://github.com/cdepillabout/world-peace). module Servant.API.UVerb.Union ( IsMember , Unique@@ -144,4 +144,4 @@                  , Nubbed '[Int, Bool] ~ 'True                  )                => a) -> a-_testNubbed = id+_testNubbed a = a
src/Servant/Links.hs view
@@ -17,6 +17,7 @@ -- >>> :set -XDataKinds -XTypeFamilies -XTypeOperators -- >>> import Servant.API -- >>> import Servant.Links+-- >>> import Web.HttpApiData (toUrlPiece) -- >>> import Data.Proxy -- >>> -- >>> type Hello = "hello" :> Get '[JSON] Int@@ -177,6 +178,7 @@ import           Servant.API.Sub                  (type (:>)) import           Servant.API.TypeLevel+import           Servant.API.UVerb import           Servant.API.Vault                  (Vault) import           Servant.API.Verbs@@ -573,6 +575,11 @@  instance HasLink (Stream m status fr ct a) where     type MkLink (Stream m status fr ct a) r = r+    toLink toA _ = toA++-- UVerb instances+instance HasLink (UVerb m ct a) where+    type MkLink (UVerb m ct a) r = r     toLink toA _ = toA  -- AuthProtext instances
src/Servant/Test/ComprehensiveAPI.hs view
@@ -48,7 +48,7 @@ type ComprehensiveAPIWithoutStreamingOrRaw' endpoint =     GET     :<|> "get-int"          :> Get '[JSON] Int-    :<|> "capture"          :> Capture' '[Description "example description"] "foo" Int :> GET+    :<|> "capture"          :> Capture' '[Description "example description"] "bar" Int :> GET     :<|> "capture-lenient"  :> Capture' '[Lenient] "foo" Int :> GET     :<|> "header"           :> Header "foo" Int :> GET     :<|> "header-lenient"   :> Header' '[Required, Lenient] "bar" Int :> GET
test/Servant/API/StreamSpec.hs view
@@ -90,7 +90,7 @@ runRenderFrames f = fmap mconcat . runExcept . runSourceT . f . source  runUnrenderFrames :: (SourceT Identity b -> SourceT Identity a) -> [b] -> [Either String a]-runUnrenderFrames f = go . Effect . flip unSourceT return . f . source where+runUnrenderFrames f = go . Effect . (\x -> unSourceT x return) . f . source where     go :: StepT Identity a -> [Either String a]     go Stop        = []     go (Error err) = [Left err]
test/Servant/LinksSpec.hs view
@@ -29,6 +29,9 @@   -- Fragment   :<|> "say" :> Fragment String :> Get '[JSON] NoContent +  -- UVerb+  :<|> "uverb-example" :> UVerb 'GET '[JSON] '[WithStatus 200 NoContent]+   -- All of the verbs   :<|> "get" :> Get '[JSON] NoContent   :<|> "put" :> Put '[JSON] NoContent@@ -72,6 +75,10 @@         apiLink (Proxy :: Proxy ("all" :> CaptureAll "names" String :> Get '[JSON] NoContent))           ["roads", "lead", "to", "rome"]           `shouldBeLink` "all/roads/lead/to/rome"++    it "generated correct links for UVerbs" $ do+      apiLink (Proxy :: Proxy ("uverb-example" :> UVerb 'GET '[JSON] '[WithStatus 200 NoContent]))+        `shouldBeLink` "uverb-example"      it "generates correct links for query flags" $ do         let l1 = Proxy :: Proxy ("balls" :> QueryFlag "bouncy"