on master help sign in
rename JsonBody to ReqBody
82a7428Alp Mestanogullari
example/greet.hs+1−1
@@ -51,7 +51,7 @@ instance ToSample Greet where
51-- API specification
51-- API specification
52type TestApi =
52type TestApi =
53 "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
53 "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
54− :<|> "greet" :> JsonBody Greet :> Post Greet
54+ :<|> "greet" :> ReqBody Greet :> Post Greet
55 :<|> "delete" :> Capture "greetid" Text :> Delete
55 :<|> "delete" :> Capture "greetid" Text :> Delete
56
56
57testApi :: Proxy TestApi
57testApi :: Proxy TestApi
servant.cabal+1−1
@@ -22,10 +22,10 @@ library
22 Servant.API.Capture
22 Servant.API.Capture
23 Servant.API.Delete
23 Servant.API.Delete
24 Servant.API.Get
24 Servant.API.Get
25− Servant.API.JsonBody
26 Servant.API.Post
25 Servant.API.Post
27 Servant.API.Put
26 Servant.API.Put
28 Servant.API.QueryParam
27 Servant.API.QueryParam
28+ Servant.API.ReqBody
29 Servant.API.Raw
29 Servant.API.Raw
30 Servant.API.Sub
30 Servant.API.Sub
31 Servant.API.Union
31 Servant.API.Union
src/Servant/API.hs+3−3
@@ -9,10 +9,10 @@ module Servant.API (
9 -- * Accessing information from the request
9 -- * Accessing information from the request
10 -- | Capturing parts of the url path as parsed values: @'Capture'@
10 -- | Capturing parts of the url path as parsed values: @'Capture'@
11 module Servant.API.Capture,
11 module Servant.API.Capture,
12− -- | Accessing the request body as a JSON-encoded type: @'JsonBody'@
13− module Servant.API.JsonBody,
14 -- | Retrieving parameters from the query string of the 'URI': @'QueryParam'@
12 -- | Retrieving parameters from the query string of the 'URI': @'QueryParam'@
15 module Servant.API.QueryParam,
13 module Servant.API.QueryParam,
14+ -- | Accessing the request body as a JSON-encoded type: @'ReqBody'@
15+ module Servant.API.ReqBody,
16
16
17 -- * Actual endpoints, distinguished by HTTP method
17 -- * Actual endpoints, distinguished by HTTP method
18 -- | GET requests
18 -- | GET requests
@@ -28,9 +28,9 @@ module Servant.API (
28import Servant.API.Capture
28import Servant.API.Capture
29import Servant.API.Delete
29import Servant.API.Delete
30import Servant.API.Get
30import Servant.API.Get
31−import Servant.API.JsonBody
32import Servant.API.Post
31import Servant.API.Post
33import Servant.API.Put
32import Servant.API.Put
34import Servant.API.QueryParam
33import Servant.API.QueryParam
34+import Servant.API.ReqBody
35import Servant.API.Sub
35import Servant.API.Sub
36import Servant.API.Union
36import Servant.API.Union
src/Servant/API/JsonBody.hs → src/Servant/API/ReqBody.hsrenamed+7−7
@@ -3,7 +3,7 @@
3{-# LANGUAGE TypeOperators #-}
3{-# LANGUAGE TypeOperators #-}
4{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE ScopedTypeVariables #-}
5{-# LANGUAGE ScopedTypeVariables #-}
6−module Servant.API.JsonBody where
6+module Servant.API.ReqBody where
7
7
8import Control.Applicative
8import Control.Applicative
9import Data.Aeson
9import Data.Aeson
@@ -15,12 +15,12 @@ import Servant.Docs
15import Servant.Server
15import Servant.Server
16
16
17-- * Request Body support
17-- * Request Body support
18−data JsonBody a
18+data ReqBody a
19
19
20instance (FromJSON a, HasServer sublayout)
20instance (FromJSON a, HasServer sublayout)
21− => HasServer (JsonBody a :> sublayout) where
21+ => HasServer (ReqBody a :> sublayout) where
22
22
23− type Server (JsonBody a :> sublayout) =
23+ type Server (ReqBody a :> sublayout) =
24 a -> Server sublayout
24 a -> Server sublayout
25
25
26 route Proxy subserver request respond = do
26 route Proxy subserver request respond = do
@@ -30,9 +30,9 @@ instance (FromJSON a, HasServer sublayout)
30 Just v -> route (Proxy :: Proxy sublayout) (subserver v) request respond
30 Just v -> route (Proxy :: Proxy sublayout) (subserver v) request respond
31
31
32instance (ToJSON a, HasClient sublayout)
32instance (ToJSON a, HasClient sublayout)
33− => HasClient (JsonBody a :> sublayout) where
33+ => HasClient (ReqBody a :> sublayout) where
34
34
35− type Client (JsonBody a :> sublayout) =
35+ type Client (ReqBody a :> sublayout) =
36 a -> Client sublayout
36 a -> Client sublayout
37
37
38 clientWithRoute Proxy req body =
38 clientWithRoute Proxy req body =
@@ -40,7 +40,7 @@ instance (ToJSON a, HasClient sublayout)
40 setRQBody (encode body) req
40 setRQBody (encode body) req
41
41
42instance (ToSample a, HasDocs sublayout)
42instance (ToSample a, HasDocs sublayout)
43− => HasDocs (JsonBody a :> sublayout) where
43+ => HasDocs (ReqBody a :> sublayout) where
44
44
45 docsFor Proxy (endpoint, action) =
45 docsFor Proxy (endpoint, action) =
46 docsFor sublayoutP (endpoint, action')
46 docsFor sublayoutP (endpoint, action')