packages feed

servant 0.7.1 → 0.8

raw patch · 9 files changed

+57/−52 lines, 9 filesdep ~aesondep ~attoparsecdep ~base-compat

Dependency ranges changed: aeson, attoparsec, base-compat, case-insensitive, mmorph, mtl, network-uri, text

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+0.8+---++* Minor fixes, documentation changes and cabal tweaks+ 0.7.1 ----- 
servant.cabal view
@@ -1,5 +1,5 @@ name:                servant-version:             0.7.1+version:             0.8 synopsis:            A family of combinators for defining webservices APIs description:   A family of combinators for defining webservices APIs and serving them@@ -49,22 +49,22 @@     Servant.Utils.Links     Servant.Utils.Enter   build-depends:-      base >= 4.7 && < 4.10-    , base-compat >= 0.9-    , aeson >= 0.7-    , attoparsec >= 0.12-    , bytestring == 0.10.*-    , bytestring-conversion == 0.3.*-    , case-insensitive >= 1.2-    , http-api-data >= 0.1  && < 0.3-    , http-media >= 0.4 && < 0.7-    , http-types >= 0.8 && < 0.10-    , mtl >= 2 && < 3-    , mmorph >= 1-    , text >= 1 && < 2-    , string-conversions >= 0.3 && < 0.5-    , network-uri >= 2.6-    , vault >= 0.3 && <0.4+      base                  >= 4.7  && < 4.10+    , base-compat           >= 0.9  && < 0.10+    , aeson                 >= 0.7  && < 0.12+    , attoparsec            >= 0.12 && < 0.14+    , bytestring            >= 0.10 && < 0.11+    , bytestring-conversion >= 0.3  && < 0.4+    , case-insensitive      >= 1.2  && < 1.3+    , http-api-data         >= 0.1  && < 0.3+    , http-media            >= 0.4  && < 0.7+    , http-types            >= 0.8  && < 0.10+    , mtl                   >= 2.0  && < 2.3+    , mmorph                >= 1    && < 1.1+    , text                  >= 1    && < 1.3+    , string-conversions    >= 0.3  && < 0.5+    , network-uri           >= 2.6  && < 2.7+    , vault                 >= 0.3  && < 0.4   hs-source-dirs: src   default-language: Haskell2010   other-extensions: CPP@@ -104,6 +104,7 @@       Servant.Utils.LinksSpec   build-depends:       base == 4.*+    , base-compat     , aeson     , attoparsec     , bytestring
src/Servant/API/Alternative.hs view
@@ -1,9 +1,7 @@ {-# LANGUAGE CPP                #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveFunctor      #-}-#if !MIN_VERSION_base(4,8,0) {-# LANGUAGE DeriveFoldable     #-}-#endif {-# LANGUAGE DeriveTraversable  #-} {-# LANGUAGE TypeOperators      #-} {-# OPTIONS_HADDOCK not-home    #-}
src/Servant/API/ContentTypes.hs view
@@ -154,7 +154,7 @@ -- > instance Accept MyContentType where -- >    contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8") -- >--- > instance Show a => MimeRender MyContentType where+-- > instance Show a => MimeRender MyContentType a where -- >    mimeRender _ val = pack ("This is MINE! " ++ show val) -- > -- > type MyAPI = "path" :> Get '[MyContentType] Int@@ -319,7 +319,7 @@  -- | A type for responses without content-body. data NoContent = NoContent-  deriving (Show, Eq, Read)+  deriving (Show, Eq, Read, Generic)   --------------------------------------------------------------------------
src/Servant/API/Internal/Test/ComprehensiveAPI.hs view
@@ -10,7 +10,7 @@  import           Servant.API -type GET = Get '[JSON] ()+type GET = Get '[JSON] NoContent  type ComprehensiveAPI =   GET :<|>@@ -25,10 +25,10 @@ -- Raw :<|>   RemoteHost :> GET :<|>   ReqBody '[JSON] Int :> GET :<|>-  Get '[JSON] (Headers '[Header "foo" Int] ()) :<|>+  Get '[JSON] (Headers '[Header "foo" Int] NoContent) :<|>   "foo" :> GET :<|>   Vault :> GET :<|>-  Verb 'POST 204 '[JSON] () :<|>+  Verb 'POST 204 '[JSON] NoContent :<|>   Verb 'POST 204 '[JSON] Int :<|>   WithNamedContext "foo" '[] GET 
src/Servant/Utils/Enter.hs view
@@ -11,9 +11,6 @@ module Servant.Utils.Enter where  import qualified Control.Category            as C-#if MIN_VERSION_mtl(2,2,1)-import           Control.Monad.Except-#endif import           Control.Monad.Identity import           Control.Monad.Morph import           Control.Monad.Reader
src/Servant/Utils/Links.hs view
@@ -21,7 +21,7 @@ -- >>> -- >>> -- >>> type Hello = "hello" :> Get '[JSON] Int--- >>> type Bye   = "bye"   :> QueryParam "name" String :> Delete '[JSON] ()+-- >>> type Bye   = "bye"   :> QueryParam "name" String :> Delete '[JSON] NoContent -- >>> type API   = Hello :<|> Bye -- >>> let api = Proxy :: Proxy API --@@ -47,11 +47,11 @@ -- If the API has an endpoint with parameters then we can generate links with -- or without those: ----- >>> let with = Proxy :: Proxy ("bye" :> QueryParam "name" String :> Delete '[JSON] ())+-- >>> let with = Proxy :: Proxy ("bye" :> QueryParam "name" String :> Delete '[JSON] NoContent) -- >>> print $ safeLink api with (Just "Hubert") -- bye?name=Hubert ----- >>> let without = Proxy :: Proxy ("bye" :> Delete '[JSON] ())+-- >>> let without = Proxy :: Proxy ("bye" :> Delete '[JSON] NoContent) -- >>> print $ safeLink api without -- bye --@@ -69,7 +69,7 @@ -- Attempting to construct a link to an endpoint that does not exist in api -- will result in a type error like this: ----- >>> let bad_link = Proxy :: Proxy ("hello" :> Delete '[JSON] ())+-- >>> let bad_link = Proxy :: Proxy ("hello" :> Delete '[JSON] NoContent) -- >>> safeLink api bad_link -- ... -- ...Could not deduce...@@ -106,6 +106,7 @@ import           Prelude.Compat  import Web.HttpApiData+import Servant.API.BasicAuth ( BasicAuth ) import Servant.API.Capture ( Capture ) import Servant.API.ReqBody ( ReqBody ) import Servant.API.QueryParam ( QueryParam, QueryParams, QueryFlag )@@ -289,6 +290,10 @@  instance HasLink sub => HasLink (RemoteHost :> sub) where     type MkLink (RemoteHost :> sub) = MkLink sub+    toLink _ = toLink (Proxy :: Proxy sub)++instance HasLink sub => HasLink (BasicAuth realm a :> sub) where+    type MkLink (BasicAuth realm a :> sub) = MkLink sub     toLink _ = toLink (Proxy :: Proxy sub)  -- Verb (terminal) instances
test/Servant/API/ContentTypesSpec.hs view
@@ -8,10 +8,9 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} module Servant.API.ContentTypesSpec where -#if !MIN_VERSION_base(4,8,0)-import           Control.Applicative-import           Data.Monoid-#endif+import           Prelude ()+import           Prelude.Compat+ import           Control.Arrow import           Data.Aeson import           Data.ByteString.Char8     (ByteString, append, pack)
test/Servant/Utils/LinksSpec.hs view
@@ -12,16 +12,16 @@  type TestApi =   -- Capture and query params-       "hello" :> Capture "name" String :> QueryParam "capital" Bool :> Delete '[JSON] ()+       "hello" :> Capture "name" String :> QueryParam "capital" Bool :> Delete '[JSON] NoContent    -- Flags-  :<|> "balls" :> QueryFlag "bouncy" :> QueryFlag "fast" :> Delete '[JSON] ()+  :<|> "balls" :> QueryFlag "bouncy" :> QueryFlag "fast" :> Delete '[JSON] NoContent    -- All of the verbs-  :<|> "get" :> Get '[JSON] ()-  :<|> "put" :> Put '[JSON] ()-  :<|> "post" :> ReqBody '[JSON] 'True :> Post '[JSON] ()-  :<|> "delete" :> Header "ponies" String :> Delete '[JSON] ()+  :<|> "get" :> Get '[JSON] NoContent+  :<|> "put" :> Put '[JSON] NoContent+  :<|> "post" :> ReqBody '[JSON] 'True :> Post '[JSON] NoContent+  :<|> "delete" :> Header "ponies" String :> Delete '[JSON] NoContent   :<|> "raw" :> Raw  @@ -38,26 +38,26 @@ spec :: Spec spec = describe "Servant.Utils.Links" $ do     it "generates correct links for capture query params" $ do-        let l1 = Proxy :: Proxy ("hello" :> Capture "name" String :> Delete '[JSON] ())+        let l1 = Proxy :: Proxy ("hello" :> Capture "name" String :> Delete '[JSON] NoContent)         apiLink l1 "hi" `shouldBeURI` "hello/hi"          let l2 = Proxy :: Proxy ("hello" :> Capture "name" String                                          :> QueryParam "capital" Bool-                                         :> Delete '[JSON] ())+                                         :> Delete '[JSON] NoContent)         apiLink l2 "bye" (Just True) `shouldBeURI` "hello/bye?capital=true"       it "generates correct links for query flags" $ do         let l1 = Proxy :: Proxy ("balls" :> QueryFlag "bouncy"-                                         :> QueryFlag "fast" :> Delete '[JSON] ())+                                         :> QueryFlag "fast" :> Delete '[JSON] NoContent)         apiLink l1 True True `shouldBeURI` "balls?bouncy&fast"         apiLink l1 False True `shouldBeURI` "balls?fast"      it "generates correct links for all of the verbs" $ do-        apiLink (Proxy :: Proxy ("get" :> Get '[JSON] ())) `shouldBeURI` "get"-        apiLink (Proxy :: Proxy ("put" :> Put '[JSON] ())) `shouldBeURI` "put"-        apiLink (Proxy :: Proxy ("post" :> Post '[JSON] ())) `shouldBeURI` "post"-        apiLink (Proxy :: Proxy ("delete" :> Delete '[JSON] ())) `shouldBeURI` "delete"+        apiLink (Proxy :: Proxy ("get" :> Get '[JSON] NoContent)) `shouldBeURI` "get"+        apiLink (Proxy :: Proxy ("put" :> Put '[JSON] NoContent)) `shouldBeURI` "put"+        apiLink (Proxy :: Proxy ("post" :> Post '[JSON] NoContent)) `shouldBeURI` "post"+        apiLink (Proxy :: Proxy ("delete" :> Delete '[JSON] NoContent)) `shouldBeURI` "delete"         apiLink (Proxy :: Proxy ("raw" :> Raw)) `shouldBeURI` "raw"  @@ -93,9 +93,9 @@ -- sanity check -- >>> apiLink (Proxy :: Proxy AllGood) -- get-type WrongPath = "getTypo" :> Get '[JSON] ()+type WrongPath = "getTypo" :> Get '[JSON] NoContent type WrongReturnType = "get" :> Get '[JSON] Bool-type WrongContentType = "get" :> Get '[OctetStream] ()-type WrongMethod = "get" :> Post '[JSON] ()+type WrongContentType = "get" :> Get '[OctetStream] NoContent+type WrongMethod = "get" :> Post '[JSON] NoContent type NotALink = "hello" :> ReqBody '[JSON] 'True :> Get '[JSON] Bool-type AllGood = "get" :> Get '[JSON] ()+type AllGood = "get" :> Get '[JSON] NoContent