on master help sign in
Merge tag 'v0.8' into client-ghcjs_7.1
commit187fe5b139b37363ed127a9816e25ef31858099f authorSönke Hahn <soenkehahn@gmail.com> dateTue 19 Jul 2016, 16:27 (10 years ago) parent6c5afe88eb412f
29 files changed+165−139
doc/tutorial/tutorial.cabal+7−6 servant-client/servant-client.cabal+24−22 servant-client/src/Servant/Common/Req.hs+8−3 servant-client/test/ghcjs/testServer/package.yaml+1 servant-client/test/ghcjs/testServer/testServer.cabal+2−1 servant-docs/example/greet.hs+2−2 servant-docs/servant-docs.cabal+2−2 servant-docs/src/Servant/Docs/Internal.hs+1−1 servant-foreign/servant-foreign.cabal+2−2 servant-foreign/src/Servant/Foreign/Internal.hs+6−6 servant-foreign/test/Servant/ForeignSpec.hs+4−4 servant-js/servant-js.cabal+5−4 servant-js/src/Servant/JS.hs+6−5 servant-js/src/Servant/JS/Internal.hs+2−2 servant-js/test/Servant/JSSpec.hs+3−2 servant-js/test/Servant/JSSpec/CustomHeaders.hs+13−12 servant-mock/servant-mock.cabal+3−3 servant-mock/src/Servant/Mock.hs+3 servant-server/example/greet.hs+2−2 servant-server/servant-server.cabal+9−9 servant-server/src/Servant/Server.hs+1−1 servant-server/test/Servant/Server/RouterSpec.hs+1−1 servant-server/test/Servant/ServerSpec.hs+11−7 servant/CHANGELOG.md+5 servant/servant.cabal+17−17 servant/src/Servant/API/ContentTypes.hs+1−1 servant/src/Servant/API/Internal/Test/ComprehensiveAPI.hs+3−3 servant/src/Servant/Utils/Links.hs+4−4 servant/test/Servant/Utils/LinksSpec.hs+17−17
doc/tutorial/tutorial.cabal+7−6
@@ -1,5 +1,5 @@
11name: tutorial
2−version: 0.7.1
2+version: 0.8
33synopsis: The servant tutorial
44homepage: http://haskell-servant.readthedocs.org/
55license: BSD3
@@ -25,11 +25,11 @@ library
2525 , directory
2626 , blaze-markup
2727 , containers
28− , servant == 0.7.*
29− , servant-server == 0.7.*
30− , servant-client == 0.7.*
31− , servant-docs == 0.7.*
32− , servant-js == 0.7.*
28+ , servant == 0.8.*
29+ , servant-server == 0.8.*
30+ , servant-client == 0.8.*
31+ , servant-docs == 0.8.*
32+ , servant-js == 0.8.*
3333 , warp
3434 , http-media
3535 , lucid
@@ -54,6 +54,7 @@ test-suite spec
5454 default-language: Haskell2010
5555 hs-source-dirs: test
5656 main-is: Spec.hs
57+ other-modules: JavascriptSpec
5758 build-depends: base == 4.*
5859 , tutorial
5960 , hspec
servant-client/servant-client.cabal+24−22
@@ -1,5 +1,5 @@
11name: servant-client
2−version: 0.7.1
2+version: 0.8
33synopsis: automatical derivation of querying functions for servant webservices
44description:
55 This library lets you derive automatically Haskell functions that
@@ -44,29 +44,29 @@ library
4444 other-modules:
4545 Servant.Client.PerformRequest.GHC
4646 build-depends:
47− base >=4.7 && <5
48− , aeson
49− , attoparsec
50− , base64-bytestring
51− , bytestring
52− , case-insensitive
53− , exceptions
54− , http-api-data >= 0.1 && < 0.3
55− , http-client <0.5
56− , http-client-tls
57− , http-media
58− , http-types
59− , network-uri >= 2.6
60− , safe
61− , servant == 0.7.*
62− , string-conversions
63− , text
64− , transformers
65− , transformers-compat
47+ base >= 4.7 && < 4.10
48+ , aeson >= 0.7 && < 0.12
49+ , attoparsec >= 0.12 && < 0.14
50+ , base64-bytestring >= 1.0.0.1 && < 1.1
51+ , bytestring >= 0.10 && < 0.11
52+ , exceptions >= 0.8 && < 0.9
53+ , http-api-data >= 0.1 && < 0.3
54+ , http-client >= 0.4.18.1 && < 0.6
55+ , http-client-tls >= 0.2.2 && < 0.4
56+ , http-media >= 0.6.2 && < 0.7
57+ , http-types >= 0.8.6 && < 0.10
58+ , network-uri >= 2.6 && < 2.7
59+ , safe >= 0.3.9 && < 0.4
60+ , servant == 0.8.*
61+ , string-conversions >= 0.3 && < 0.5
62+ , text >= 1.2 && < 1.3
63+ , transformers >= 0.3 && < 0.6
64+ , transformers-compat >= 0.4 && < 0.6
6665 if impl(ghcjs)
6766 build-depends:
6867 ghcjs-base
6968 , ghcjs-prim
69+ , case-insensitive
7070 hs-source-dirs: src
7171 default-language: Haskell2010
7272 ghc-options: -Wall
@@ -77,6 +77,8 @@ library
7777test-suite spec
7878 type: exitcode-stdio-1.0
7979 ghc-options: -Wall -fno-warn-name-shadowing
80+ if impl(ghc >= 8.0)
81+ ghc-options: -Wno-redundant-constraints
8082 default-language: Haskell2010
8183 hs-source-dirs: test, src
8284 main-is: Spec.hs
@@ -110,8 +112,8 @@ test-suite spec
110112 , HUnit
111113 , network >= 2.6
112114 , QuickCheck >= 2.7
113− , servant == 0.7.*
114− , servant-server == 0.7.*
115+ , servant == 0.8.*
116+ , servant-server == 0.8.*
115117 , text
116118 , wai
117119 , warp
servant-client/src/Servant/Common/Req.hs+8−3
@@ -112,9 +112,8 @@ performRequest :: Method -> Req -> Manager -> BaseUrl
112112performRequest reqMethod req manager reqHost = do
113113 partialRequest <- liftIO $ reqToRequest req reqHost
114114
115− let request = partialRequest { Client.method = reqMethod
116− , checkStatus = \ _status _headers _cookies -> Nothing
117− }
115+ let request = disableStatusCheck $
116+ partialRequest { Client.method = reqMethod }
118117
119118 eResponse <- liftIO $ performHttpRequest manager request
120119 case eResponse of
@@ -135,6 +134,12 @@ performRequest reqMethod req manager reqHost = do
135134 throwE $ FailureResponse status ct body
136135 return (status_code, body, ct, hdrs, response)
137136
137+disableStatusCheck :: Request -> Request
138+#if MIN_VERSION_http_client(0,5,0)
139+disableStatusCheck req = req { checkResponse = \ _req _res -> return () }
140+#else
141+disableStatusCheck req = req { checkStatus = \ _status _headers _cookies -> Nothing }
142+#endif
138143
139144performRequestCT :: MimeUnrender ct result =>
140145 Proxy ct -> Method -> Req -> Manager -> BaseUrl
servant-client/test/ghcjs/testServer/package.yaml+1
@@ -6,6 +6,7 @@ executables:
66 other-modules: []
77 dependencies:
88 - base
9+ - base-compat
910 - aeson
1011 - base64-bytestring
1112 - bytestring
servant-client/test/ghcjs/testServer/testServer.cabal+2−1
@@ -1,4 +1,4 @@
1−-- This file has been generated from package.yaml by hpack version 0.13.0.
1+-- This file has been generated from package.yaml by hpack version 0.14.0.
22--
33-- see: https://github.com/sol/hpack
44
@@ -17,6 +17,7 @@ executable testServer
1717 ../../../include
1818 build-depends:
1919 base
20+ , base-compat
2021 , aeson
2122 , base64-bytestring
2223 , bytestring
servant-docs/example/greet.hs+2−2
@@ -81,7 +81,7 @@ type TestApi =
8181 :<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] (Headers '[Header "X-Example" Int] Greet)
8282
8383 -- DELETE /greet/:greetid
84− :<|> "greet" :> Capture "greetid" Text :> Delete '[JSON] ()
84+ :<|> "greet" :> Capture "greetid" Text :> Delete '[JSON] NoContent
8585
8686testApi :: Proxy TestApi
8787testApi = Proxy
@@ -91,7 +91,7 @@ testApi = Proxy
9191-- notes.
9292extra :: ExtraInfo TestApi
9393extra =
94− extraInfo (Proxy :: Proxy ("greet" :> Capture "greetid" Text :> Delete '[JSON] ())) $
94+ extraInfo (Proxy :: Proxy ("greet" :> Capture "greetid" Text :> Delete '[JSON] NoContent)) $
9595 defAction & headers <>~ ["unicorns"]
9696 & notes <>~ [ DocNote "Title" ["This is some text"]
9797 , DocNote "Second secton" ["And some more"]
servant-docs/servant-docs.cabal+2−2
@@ -1,5 +1,5 @@
11name: servant-docs
2−version: 0.7.1
2+version: 0.8
33synopsis: generate API docs for your servant webservice
44description:
55 Library for generating API docs from a servant API definition.
@@ -42,7 +42,7 @@ library
4242 , http-media >= 0.6
4343 , http-types >= 0.7
4444 , lens
45− , servant == 0.7.*
45+ , servant == 0.8.*
4646 , string-conversions
4747 , text
4848 , unordered-containers
servant-docs/src/Servant/Docs/Internal.hs+1−1
@@ -833,7 +833,7 @@ instance (ToAuthInfo (BasicAuth realm usr), HasDocs api) => HasDocs (BasicAuth r
833833 action' = over authInfo (|> toAuthInfo authProxy) action
834834
835835-- ToSample instances for simple types
836−instance ToSample ()
836+instance ToSample NoContent
837837instance ToSample Bool
838838instance ToSample Ordering
839839
servant-foreign/servant-foreign.cabal+2−2
@@ -1,5 +1,5 @@
11name: servant-foreign
2−version: 0.7.1
2+version: 0.8
33synopsis: Helpers for generating clients for servant APIs in any programming language
44description:
55 Helper types and functions for generating client functions for servant APIs in any programming language
@@ -32,7 +32,7 @@ library
3232 , Servant.Foreign.Inflections
3333 build-depends: base == 4.*
3434 , lens == 4.*
35− , servant == 0.7.*
35+ , servant == 0.8.*
3636 , text >= 1.2 && < 1.3
3737 , http-types
3838 hs-source-dirs: src
servant-foreign/src/Servant/Foreign/Internal.hs+6−6
@@ -169,11 +169,11 @@ type family Elem (a :: *) (ls::[*]) :: Constraint where
169169-- > getEndpoints api = listFromAPI (Proxy :: Proxy LangX) (Proxy :: Proxy Text) api
170170--
171171-- > -- If language __X__ is dynamically typed then you can use
172−-- > -- a predefined NoTypes parameter with the () output type:
172+-- > -- a predefined NoTypes parameter with the NoContent output type:
173173--
174−-- > getEndpoints :: (HasForeign NoTypes () api, GenerateList Text (Foreign () api))
175−-- > => Proxy api -> [Req ()]
176−-- > getEndpoints api = listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy ()) api
174+-- > getEndpoints :: (HasForeign NoTypes NoContent api, GenerateList Text (Foreign NoContent api))
175+-- > => Proxy api -> [Req NoContent]
176+-- > getEndpoints api = listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy NoContent) api
177177-- >
178178--
179179class HasForeignType lang ftype a where
@@ -181,8 +181,8 @@ class HasForeignType lang ftype a where
181181
182182data NoTypes
183183
184−instance HasForeignType NoTypes () ftype where
185− typeFor _ _ _ = ()
184+instance HasForeignType NoTypes NoContent ftype where
185+ typeFor _ _ _ = NoContent
186186
187187class HasForeign lang ftype (api :: *) where
188188 type Foreign ftype api :: *
servant-foreign/test/Servant/ForeignSpec.hs+4−4
@@ -26,7 +26,7 @@ camelCaseSpec = describe "camelCase" $ do
2626
2727data LangX
2828
29−instance HasForeignType LangX String () where
29+instance HasForeignType LangX String NoContent where
3030 typeFor _ _ _ = "voidX"
3131
3232instance HasForeignType LangX String Int where
@@ -43,9 +43,9 @@ instance OVERLAPPABLE_ HasForeignType LangX String a => HasForeignType LangX Str
4343
4444type TestApi
4545 = "test" :> Header "header" [String] :> QueryFlag "flag" :> Get '[JSON] Int
46− :<|> "test" :> QueryParam "param" Int :> ReqBody '[JSON] [String] :> Post '[JSON] ()
47− :<|> "test" :> QueryParams "params" Int :> ReqBody '[JSON] String :> Put '[JSON] ()
48− :<|> "test" :> Capture "id" Int :> Delete '[JSON] ()
46+ :<|> "test" :> QueryParam "param" Int :> ReqBody '[JSON] [String] :> Post '[JSON] NoContent
47+ :<|> "test" :> QueryParams "params" Int :> ReqBody '[JSON] String :> Put '[JSON] NoContent
48+ :<|> "test" :> Capture "id" Int :> Delete '[JSON] NoContent
4949
5050testApi :: [Req String]
5151testApi = listFromAPI (Proxy :: Proxy LangX) (Proxy :: Proxy String) (Proxy :: Proxy TestApi)
servant-js/servant-js.cabal+5−4
@@ -1,5 +1,5 @@
11name: servant-js
2−version: 0.7.1
2+version: 0.8
33synopsis: Automatically derive javascript functions to query servant webservices.
44description:
55 Automatically derive javascript functions to query servant webservices.
@@ -45,7 +45,8 @@ library
4545 , base-compat >= 0.9
4646 , charset >= 0.3
4747 , lens >= 4
48− , servant-foreign == 0.7.*
48+ , servant-foreign == 0.8.*
49+ , servant == 0.8.*
4950 , text >= 1.2 && < 1.3
5051
5152 hs-source-dirs: src
@@ -67,8 +68,8 @@ executable counter
6768 , aeson >= 0.7 && < 0.12
6869 , filepath >= 1
6970 , lens >= 4
70− , servant == 0.7.*
71− , servant-server == 0.7.*
71+ , servant == 0.8.*
72+ , servant-server == 0.8.*
7273 , servant-js
7374 , stm
7475 , transformers
servant-js/src/Servant/JS.hs+6−5
@@ -118,6 +118,7 @@ import Prelude hiding (writeFile)
118118import Data.Proxy
119119import Data.Text
120120import Data.Text.IO (writeFile)
121+import Servant.API.ContentTypes
121122import Servant.JS.Angular
122123import Servant.JS.Axios
123124import Servant.JS.Internal
@@ -128,22 +129,22 @@ import Servant.Foreign (listFromAPI)
128129-- | Generate the data necessary to generate javascript code
129130-- for all the endpoints of an API, as ':<|>'-separated values
130131-- of type 'AjaxReq'.
131−javascript :: HasForeign NoTypes () api => Proxy api -> Foreign () api
132−javascript p = foreignFor (Proxy :: Proxy NoTypes) (Proxy :: Proxy ()) p defReq
132+javascript :: HasForeign NoTypes NoContent api => Proxy api -> Foreign NoContent api
133+javascript p = foreignFor (Proxy :: Proxy NoTypes) (Proxy :: Proxy NoContent) p defReq
133134
134135-- | Directly generate all the javascript functions for your API
135136-- from a 'Proxy' for your API type. You can then write it to
136137-- a file or integrate it in a page, for example.
137−jsForAPI :: (HasForeign NoTypes () api, GenerateList () (Foreign () api))
138+jsForAPI :: (HasForeign NoTypes NoContent api, GenerateList NoContent (Foreign NoContent api))
138139 => Proxy api -- ^ proxy for your API type
139140 -> JavaScriptGenerator -- ^ js code generator to use (angular, vanilla js, jquery, others)
140141 -> Text -- ^ a text that you can embed in your pages or write to a file
141−jsForAPI p gen = gen (listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy ()) p)
142+jsForAPI p gen = gen (listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy NoContent) p)
142143
143144-- | Directly generate all the javascript functions for your API
144145-- from a 'Proxy' for your API type using the given generator
145146-- and write the resulting code to a file at the given path.
146−writeJSForAPI :: (HasForeign NoTypes () api, GenerateList () (Foreign () api))
147+writeJSForAPI :: (HasForeign NoTypes NoContent api, GenerateList NoContent (Foreign NoContent api))
147148 => Proxy api -- ^ proxy for your API type
148149 -> JavaScriptGenerator -- ^ js code generator to use (angular, vanilla js, jquery, others)
149150 -> FilePath -- ^ path to the file you want to write the resulting javascript code into
servant-js/src/Servant/JS/Internal.hs+2−2
@@ -54,12 +54,12 @@ import qualified Data.Text as T
5454import Data.Text (Text)
5555import Servant.Foreign
5656
57−type AjaxReq = Req ()
57+type AjaxReq = Req NoContent
5858
5959-- A 'JavascriptGenerator' just takes the data found in the API type
6060-- for each endpoint and generates Javascript code in a Text. Several
6161-- generators are available in this package.
62−type JavaScriptGenerator = [Req ()] -> Text
62+type JavaScriptGenerator = [Req NoContent] -> Text
6363
6464-- | This structure is used by specific implementations to let you
6565-- customize the output
servant-js/test/Servant/JSSpec.hs+3−2
@@ -21,6 +21,7 @@ import Prelude.Compat
2121import Test.Hspec hiding (shouldContain, shouldNotContain)
2222
2323import Servant.API.Internal.Test.ComprehensiveAPI
24+import Servant.API.ContentTypes
2425import Servant.JS
2526import Servant.JS.Internal
2627import qualified Servant.JS.Angular as NG
@@ -105,7 +106,7 @@ a `shouldNotContain` b = shouldNotSatisfy a (T.isInfixOf b)
105106
106107axiosSpec :: Spec
107108axiosSpec = describe specLabel $ do
108− let reqList = listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy ()) (Proxy :: Proxy TestAPI)
109+ let reqList = listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy NoContent) (Proxy :: Proxy TestAPI)
109110 it "should add withCredentials when needed" $ do
110111 let jsText = genJS withCredOpts $ reqList
111112 output jsText
@@ -129,7 +130,7 @@ axiosSpec = describe specLabel $ do
129130
130131angularSpec :: TestNames -> Spec
131132angularSpec test = describe specLabel $ do
132− let reqList = listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy ()) (Proxy :: Proxy TestAPI)
133+ let reqList = listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy NoContent) (Proxy :: Proxy TestAPI)
133134 it "should implement a service globally" $ do
134135 let jsText = genJS reqList
135136 output jsText
servant-js/test/Servant/JSSpec/CustomHeaders.hs+13−12
@@ -16,6 +16,7 @@ import Data.Monoid
1616import Data.Proxy
1717import Data.Text (pack)
1818import GHC.TypeLits
19+import Servant.API.ContentTypes
1920import Servant.JS.Internal
2021
2122-- | This is a hypothetical combinator that fetches an Authorization header.
@@ -23,13 +24,13 @@ import Servant.JS.Internal
2324-- using -- Basic, Digest, whatever.
2425data Authorization (sym :: Symbol) a
2526
26−instance (KnownSymbol sym, HasForeign lang () api)
27− => HasForeign lang () (Authorization sym a :> api) where
28− type Foreign () (Authorization sym a :> api) = Foreign () api
27+instance (KnownSymbol sym, HasForeign lang NoContent api)
28+ => HasForeign lang NoContent (Authorization sym a :> api) where
29+ type Foreign NoContent (Authorization sym a :> api) = Foreign NoContent api
2930
3031 foreignFor lang ftype Proxy req = foreignFor lang ftype (Proxy :: Proxy api) $
3132 req & reqHeaders <>~
32− [ ReplaceHeaderArg (Arg "Authorization" ())
33+ [ ReplaceHeaderArg (Arg "Authorization" NoContent)
3334 $ tokenType (pack . symbolVal $ (Proxy :: Proxy sym)) ]
3435 where
3536 tokenType t = t <> " {Authorization}"
@@ -37,23 +38,23 @@ instance (KnownSymbol sym, HasForeign lang () api)
3738-- | This is a combinator that fetches an X-MyLovelyHorse header.
3839data MyLovelyHorse a
3940
40−instance (HasForeign lang () api)
41− => HasForeign lang () (MyLovelyHorse a :> api) where
42− type Foreign () (MyLovelyHorse a :> api) = Foreign () api
41+instance (HasForeign lang NoContent api)
42+ => HasForeign lang NoContent (MyLovelyHorse a :> api) where
43+ type Foreign NoContent (MyLovelyHorse a :> api) = Foreign NoContent api
4344
4445 foreignFor lang ftype Proxy req = foreignFor lang ftype (Proxy :: Proxy api) $
45− req & reqHeaders <>~ [ ReplaceHeaderArg (Arg "X-MyLovelyHorse" ()) tpl ]
46+ req & reqHeaders <>~ [ ReplaceHeaderArg (Arg "X-MyLovelyHorse" NoContent) tpl ]
4647 where
4748 tpl = "I am good friends with {X-MyLovelyHorse}"
4849
4950-- | This is a combinator that fetches an X-WhatsForDinner header.
5051data WhatsForDinner a
5152
52−instance (HasForeign lang () api)
53− => HasForeign lang () (WhatsForDinner a :> api) where
54− type Foreign () (WhatsForDinner a :> api) = Foreign () api
53+instance (HasForeign lang NoContent api)
54+ => HasForeign lang NoContent (WhatsForDinner a :> api) where
55+ type Foreign NoContent (WhatsForDinner a :> api) = Foreign NoContent api
5556
5657 foreignFor lang ftype Proxy req = foreignFor lang ftype (Proxy :: Proxy api) $
57− req & reqHeaders <>~ [ ReplaceHeaderArg (Arg "X-WhatsForDinner" ()) tpl ]
58+ req & reqHeaders <>~ [ ReplaceHeaderArg (Arg "X-WhatsForDinner" NoContent) tpl ]
5859 where
5960 tpl = "I would like {X-WhatsForDinner} with a cherry on top."
servant-mock/servant-mock.cabal+3−3
@@ -1,5 +1,5 @@
11name: servant-mock
2−version: 0.7.1
2+version: 0.8
33synopsis: Derive a mock server for free from your servant API types
44description:
55 Derive a mock server for free from your servant API types
@@ -31,8 +31,8 @@ library
3131 base >=4.7 && <5,
3232 bytestring >= 0.10 && <0.11,
3333 http-types >= 0.8 && <0.10,
34− servant == 0.7.*,
35− servant-server == 0.7.*,
34+ servant == 0.8.*,
35+ servant-server == 0.8.*,
3636 transformers >= 0.3 && <0.6,
3737 QuickCheck >= 2.7 && <2.9,
3838 wai >= 3.0 && <3.3
servant-mock/src/Servant/Mock.hs+3
@@ -180,3 +180,6 @@ instance Arbitrary (HList '[]) where
180180instance (Arbitrary a, Arbitrary (HList hs))
181181 => Arbitrary (HList (Header h a ': hs)) where
182182 arbitrary = HCons <$> fmap Header arbitrary <*> arbitrary
183+
184+instance Arbitrary NoContent where
185+ arbitrary = pure NoContent
servant-server/example/greet.hs+2−2
@@ -34,7 +34,7 @@ type TestApi =
3434 :<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] Greet
3535
3636 -- DELETE /greet/:greetid
37− :<|> "greet" :> Capture "greetid" Text :> Delete '[JSON] ()
37+ :<|> "greet" :> Capture "greetid" Text :> Delete '[JSON] NoContent
3838
3939testApi :: Proxy TestApi
4040testApi = Proxy
@@ -54,7 +54,7 @@ server = helloH :<|> postGreetH :<|> deleteGreetH
5454
5555 postGreetH greet = return greet
5656
57− deleteGreetH _ = return ()
57+ deleteGreetH _ = return NoContent
5858
5959-- Turn the server into a WAI app. 'serve' is provided by servant,
6060-- more precisely by the Servant.Server module.
servant-server/servant-server.cabal+9−9
@@ -1,5 +1,5 @@
11name: servant-server
2−version: 0.7.1
2+version: 0.8
33synopsis: A family of combinators for defining webservices APIs and serving them
44description:
55 A family of combinators for defining webservices APIs and serving them
@@ -45,31 +45,31 @@ library
4545 Servant.Server.Internal.ServantErr
4646 Servant.Utils.StaticFiles
4747 build-depends:
48− base >= 4.7 && < 5
49− , base-compat >= 0.9
48+ base >= 4.7 && < 4.10
49+ , base-compat >= 0.9 && < 0.10
5050 , aeson >= 0.7 && < 0.12
5151 , attoparsec >= 0.12 && < 0.14
52− , base64-bytestring == 1.0.*
52+ , base64-bytestring >= 1.0 && < 1.1
5353 , bytestring >= 0.10 && < 0.11
5454 , containers >= 0.5 && < 0.6
5555 , http-api-data >= 0.1 && < 0.3
5656 , http-types >= 0.8 && < 0.10
5757 , network-uri >= 2.6 && < 2.7
58− , mtl >= 2 && < 3
58+ , mtl >= 2 && < 2.3
5959 , network >= 2.6 && < 2.7
6060 , safe >= 0.3 && < 0.4
61− , servant == 0.7.*
61+ , servant == 0.8.*
6262 , split >= 0.2 && < 0.3
6363 , string-conversions >= 0.3 && < 0.5
6464 , system-filepath >= 0.4 && < 0.5
65− , filepath >= 1
65+ , filepath >= 1 && < 1.5
6666 , text >= 1.2 && < 1.3
6767 , transformers >= 0.3 && < 0.6
68− , transformers-compat>= 0.4
68+ , transformers-compat>= 0.4 && < 0.6
6969 , wai >= 3.0 && < 3.3
7070 , wai-app-static >= 3.1 && < 3.2
7171 , warp >= 3.0 && < 3.3
72− , word8 == 0.1.*
72+ , word8 >= 0.1 && < 0.2
7373
7474 hs-source-dirs: src
7575 default-language: Haskell2010
servant-server/src/Servant/Server.hs+1−1
@@ -147,7 +147,7 @@ serveWithContext p context server =
147147-- For the following API
148148--
149149-- > type API =
150−-- > "a" :> "d" :> Get '[JSON] ()
150+-- > "a" :> "d" :> Get '[JSON] NoContent
151151-- > :<|> "b" :> Capture "x" Int :> Get '[JSON] Bool
152152-- > :<|> "c" :> Put '[JSON] Bool
153153-- > :<|> "a" :> "e" :> Get '[JSON] Int
servant-server/test/Servant/Server/RouterSpec.hs+1−1
@@ -74,7 +74,7 @@ makeTrivialRouter :: (HasServer layout '[]) => Proxy layout -> Router ()
7474makeTrivialRouter p =
7575 route p EmptyContext (emptyDelayed (FailFatal err501))
7676
77−type End = Get '[JSON] ()
77+type End = Get '[JSON] NoContent
7878
7979-- The latter version looks more efficient,
8080-- but the former should be compiled to the
servant-server/test/Servant/ServerSpec.hs+11−7
@@ -340,19 +340,23 @@ reqBodySpec = describe "Servant.API.ReqBody" $ do
340340-- * headerSpec {{{
341341------------------------------------------------------------------------------
342342
343−type HeaderApi a = Header "MyHeader" a :> Delete '[JSON] ()
343+type HeaderApi a = Header "MyHeader" a :> Delete '[JSON] NoContent
344344headerApi :: Proxy (HeaderApi a)
345345headerApi = Proxy
346346
347347headerSpec :: Spec
348348headerSpec = describe "Servant.API.Header" $ do
349349
350− let expectsInt :: Maybe Int -> Handler ()
351− expectsInt (Just x) = when (x /= 5) $ error "Expected 5"
350+ let expectsInt :: Maybe Int -> Handler NoContent
351+ expectsInt (Just x) = do
352+ when (x /= 5) $ error "Expected 5"
353+ return NoContent
352354 expectsInt Nothing = error "Expected an int"
353355
354− let expectsString :: Maybe String -> Handler ()
355− expectsString (Just x) = when (x /= "more from you") $ error "Expected more from you"
356+ let expectsString :: Maybe String -> Handler NoContent
357+ expectsString (Just x) = do
358+ when (x /= "more from you") $ error "Expected more from you"
359+ return NoContent
356360 expectsString Nothing = error "Expected a string"
357361
358362 with (return (serve headerApi expectsInt)) $ do
@@ -410,7 +414,7 @@ type AlternativeApi =
410414 :<|> "foo" :> Get '[PlainText] T.Text
411415 :<|> "bar" :> Post '[JSON] Animal
412416 :<|> "bar" :> Put '[JSON] Animal
413− :<|> "bar" :> Delete '[JSON] ()
417+ :<|> "bar" :> Delete '[JSON] NoContent
414418
415419alternativeApi :: Proxy AlternativeApi
416420alternativeApi = Proxy
@@ -422,7 +426,7 @@ alternativeServer =
422426 :<|> return "a string"
423427 :<|> return jerry
424428 :<|> return jerry
425− :<|> return ()
429+ :<|> return NoContent
426430
427431alternativeSpec :: Spec
428432alternativeSpec = do
servant/CHANGELOG.md+5
@@ -1,3 +1,8 @@
1+0.8
2+---
3+
4+* Minor fixes, documentation changes and cabal tweaks
5+
160.7.1
27-----
38
servant/servant.cabal+17−17
@@ -1,5 +1,5 @@
11name: servant
2−version: 0.7.1
2+version: 0.8
33synopsis: A family of combinators for defining webservices APIs
44description:
55 A family of combinators for defining webservices APIs and serving them
@@ -49,22 +49,22 @@ library
4949 Servant.Utils.Links
5050 Servant.Utils.Enter
5151 build-depends:
52− base >= 4.7 && < 4.10
53− , base-compat >= 0.9
54− , aeson >= 0.7
55− , attoparsec >= 0.12
56− , bytestring == 0.10.*
57− , bytestring-conversion == 0.3.*
58− , case-insensitive >= 1.2
59− , http-api-data >= 0.1 && < 0.3
60− , http-media >= 0.4 && < 0.7
61− , http-types >= 0.8 && < 0.10
62− , mtl >= 2 && < 3
63− , mmorph >= 1
64− , text >= 1 && < 2
65− , string-conversions >= 0.3 && < 0.5
66− , network-uri >= 2.6
67− , vault >= 0.3 && <0.4
52+ base >= 4.7 && < 4.10
53+ , base-compat >= 0.9 && < 0.10
54+ , aeson >= 0.7 && < 0.12
55+ , attoparsec >= 0.12 && < 0.14
56+ , bytestring >= 0.10 && < 0.11
57+ , bytestring-conversion >= 0.3 && < 0.4
58+ , case-insensitive >= 1.2 && < 1.3
59+ , http-api-data >= 0.1 && < 0.3
60+ , http-media >= 0.4 && < 0.7
61+ , http-types >= 0.8 && < 0.10
62+ , mtl >= 2.0 && < 2.3
63+ , mmorph >= 1 && < 1.1
64+ , text >= 1 && < 1.3
65+ , string-conversions >= 0.3 && < 0.5
66+ , network-uri >= 2.6 && < 2.7
67+ , vault >= 0.3 && < 0.4
6868 hs-source-dirs: src
6969 default-language: Haskell2010
7070 other-extensions: CPP
servant/src/Servant/API/ContentTypes.hs+1−1
@@ -319,7 +319,7 @@ instance MimeRender OctetStream BS.ByteString where
319319
320320-- | A type for responses without content-body.
321321data NoContent = NoContent
322− deriving (Show, Eq, Read)
322+ deriving (Show, Eq, Read, Generic)
323323
324324
325325--------------------------------------------------------------------------
servant/src/Servant/API/Internal/Test/ComprehensiveAPI.hs+3−3
@@ -10,7 +10,7 @@ import Data.Proxy
1010
1111import Servant.API
1212
13−type GET = Get '[JSON] ()
13+type GET = Get '[JSON] NoContent
1414
1515type ComprehensiveAPI =
1616 GET :<|>
@@ -25,10 +25,10 @@ type ComprehensiveAPI =
2525-- Raw :<|>
2626 RemoteHost :> GET :<|>
2727 ReqBody '[JSON] Int :> GET :<|>
28− Get '[JSON] (Headers '[Header "foo" Int] ()) :<|>
28+ Get '[JSON] (Headers '[Header "foo" Int] NoContent) :<|>
2929 "foo" :> GET :<|>
3030 Vault :> GET :<|>
31− Verb 'POST 204 '[JSON] () :<|>
31+ Verb 'POST 204 '[JSON] NoContent :<|>
3232 Verb 'POST 204 '[JSON] Int :<|>
3333 WithNamedContext "foo" '[] GET
3434
servant/src/Servant/Utils/Links.hs+4−4
@@ -21,7 +21,7 @@
2121-- >>>
2222-- >>>
2323-- >>> type Hello = "hello" :> Get '[JSON] Int
24−-- >>> type Bye = "bye" :> QueryParam "name" String :> Delete '[JSON] ()
24+-- >>> type Bye = "bye" :> QueryParam "name" String :> Delete '[JSON] NoContent
2525-- >>> type API = Hello :<|> Bye
2626-- >>> let api = Proxy :: Proxy API
2727--
@@ -47,11 +47,11 @@
4747-- If the API has an endpoint with parameters then we can generate links with
4848-- or without those:
4949--
50−-- >>> let with = Proxy :: Proxy ("bye" :> QueryParam "name" String :> Delete '[JSON] ())
50+-- >>> let with = Proxy :: Proxy ("bye" :> QueryParam "name" String :> Delete '[JSON] NoContent)
5151-- >>> print $ safeLink api with (Just "Hubert")
5252-- bye?name=Hubert
5353--
54−-- >>> let without = Proxy :: Proxy ("bye" :> Delete '[JSON] ())
54+-- >>> let without = Proxy :: Proxy ("bye" :> Delete '[JSON] NoContent)
5555-- >>> print $ safeLink api without
5656-- bye
5757--
@@ -69,7 +69,7 @@
6969-- Attempting to construct a link to an endpoint that does not exist in api
7070-- will result in a type error like this:
7171--
72−-- >>> let bad_link = Proxy :: Proxy ("hello" :> Delete '[JSON] ())
72+-- >>> let bad_link = Proxy :: Proxy ("hello" :> Delete '[JSON] NoContent)
7373-- >>> safeLink api bad_link
7474-- ...
7575-- ...Could not deduce...
servant/test/Servant/Utils/LinksSpec.hs+17−17
@@ -12,16 +12,16 @@ import Servant.API
1212
1313type TestApi =
1414 -- Capture and query params
15− "hello" :> Capture "name" String :> QueryParam "capital" Bool :> Delete '[JSON] ()
15+ "hello" :> Capture "name" String :> QueryParam "capital" Bool :> Delete '[JSON] NoContent
1616
1717 -- Flags
18− :<|> "balls" :> QueryFlag "bouncy" :> QueryFlag "fast" :> Delete '[JSON] ()
18+ :<|> "balls" :> QueryFlag "bouncy" :> QueryFlag "fast" :> Delete '[JSON] NoContent
1919
2020 -- All of the verbs
21− :<|> "get" :> Get '[JSON] ()
22− :<|> "put" :> Put '[JSON] ()
23− :<|> "post" :> ReqBody '[JSON] 'True :> Post '[JSON] ()
24− :<|> "delete" :> Header "ponies" String :> Delete '[JSON] ()
21+ :<|> "get" :> Get '[JSON] NoContent
22+ :<|> "put" :> Put '[JSON] NoContent
23+ :<|> "post" :> ReqBody '[JSON] 'True :> Post '[JSON] NoContent
24+ :<|> "delete" :> Header "ponies" String :> Delete '[JSON] NoContent
2525 :<|> "raw" :> Raw
2626
2727
@@ -38,26 +38,26 @@ shouldBeURI link expected =
3838spec :: Spec
3939spec = describe "Servant.Utils.Links" $ do
4040 it "generates correct links for capture query params" $ do
41− let l1 = Proxy :: Proxy ("hello" :> Capture "name" String :> Delete '[JSON] ())
41+ let l1 = Proxy :: Proxy ("hello" :> Capture "name" String :> Delete '[JSON] NoContent)
4242 apiLink l1 "hi" `shouldBeURI` "hello/hi"
4343
4444 let l2 = Proxy :: Proxy ("hello" :> Capture "name" String
4545 :> QueryParam "capital" Bool
46− :> Delete '[JSON] ())
46+ :> Delete '[JSON] NoContent)
4747 apiLink l2 "bye" (Just True) `shouldBeURI` "hello/bye?capital=true"
4848
4949
5050 it "generates correct links for query flags" $ do
5151 let l1 = Proxy :: Proxy ("balls" :> QueryFlag "bouncy"
52− :> QueryFlag "fast" :> Delete '[JSON] ())
52+ :> QueryFlag "fast" :> Delete '[JSON] NoContent)
5353 apiLink l1 True True `shouldBeURI` "balls?bouncy&fast"
5454 apiLink l1 False True `shouldBeURI` "balls?fast"
5555
5656 it "generates correct links for all of the verbs" $ do
57− apiLink (Proxy :: Proxy ("get" :> Get '[JSON] ())) `shouldBeURI` "get"
58− apiLink (Proxy :: Proxy ("put" :> Put '[JSON] ())) `shouldBeURI` "put"
59− apiLink (Proxy :: Proxy ("post" :> Post '[JSON] ())) `shouldBeURI` "post"
60− apiLink (Proxy :: Proxy ("delete" :> Delete '[JSON] ())) `shouldBeURI` "delete"
57+ apiLink (Proxy :: Proxy ("get" :> Get '[JSON] NoContent)) `shouldBeURI` "get"
58+ apiLink (Proxy :: Proxy ("put" :> Put '[JSON] NoContent)) `shouldBeURI` "put"
59+ apiLink (Proxy :: Proxy ("post" :> Post '[JSON] NoContent)) `shouldBeURI` "post"
60+ apiLink (Proxy :: Proxy ("delete" :> Delete '[JSON] NoContent)) `shouldBeURI` "delete"
6161 apiLink (Proxy :: Proxy ("raw" :> Raw)) `shouldBeURI` "raw"
6262
6363
@@ -93,9 +93,9 @@ spec = describe "Servant.Utils.Links" $ do
9393-- sanity check
9494-- >>> apiLink (Proxy :: Proxy AllGood)
9595-- get
96−type WrongPath = "getTypo" :> Get '[JSON] ()
96+type WrongPath = "getTypo" :> Get '[JSON] NoContent
9797type WrongReturnType = "get" :> Get '[JSON] Bool
98−type WrongContentType = "get" :> Get '[OctetStream] ()
99−type WrongMethod = "get" :> Post '[JSON] ()
98+type WrongContentType = "get" :> Get '[OctetStream] NoContent
99+type WrongMethod = "get" :> Post '[JSON] NoContent
100100type NotALink = "hello" :> ReqBody '[JSON] 'True :> Get '[JSON] Bool
101−type AllGood = "get" :> Get '[JSON] ()
101+type AllGood = "get" :> Get '[JSON] NoContent