git.iko.soy/typeable/servant
on master help sign in
rename RQBody to JsonBody everywhere
commit9b375b137fb451fdf6cfb5619b9f2813886a3896 authorAlp Mestanogullari <alpmestan@gmail.com> dateTue 28 Oct 2014, 15:29 (12 years ago) parentfc67c3b
5 files changed+16−16
example/greet.hs+1−1 servant.cabal+1−1 src/Servant/API.hs+4−4 src/Servant/API/RQBody.hs → src/Servant/API/JsonBody.hs+7−7 test/Servant/ServerSpec.hs+3−3
example/greet.hs+1−1
@@ -51,7 +51,7 @@ instance ToSample Greet where
5151-- API specification
5252type TestApi =
5353 "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
54− :<|> "greet" :> RQBody Greet :> Post Greet
54+ :<|> "greet" :> JsonBody Greet :> Post Greet
5555 :<|> "delete" :> Capture "greetid" Text :> Delete
5656
5757testApi :: Proxy TestApi
servant.cabal+1−1
@@ -22,11 +22,11 @@ library
2222 Servant.API.Capture
2323 Servant.API.Delete
2424 Servant.API.Get
25+ Servant.API.JsonBody
2526 Servant.API.Post
2627 Servant.API.Put
2728 Servant.API.QueryParam
2829 Servant.API.Raw
29− Servant.API.RQBody
3030 Servant.API.Sub
3131 Servant.API.Union
3232 Servant.Utils.Text
src/Servant/API.hs+4−4
@@ -9,10 +9,10 @@ module Servant.API (
99 -- * Accessing information from the request
1010 -- | Capturing parts of the url path as parsed values: @'Capture'@
1111 module Servant.API.Capture,
12− -- | Retrieving parameters from the query part of the 'URI': @'QueryParam'@
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'@
1315 module Servant.API.QueryParam,
14− -- | Accessing the request's body: @'RQBody'@
15− module Servant.API.RQBody,
1616
1717 -- * Actual endpoints, distinguished by HTTP method
1818 -- | GET requests
@@ -28,9 +28,9 @@ module Servant.API (
2828import Servant.API.Capture
2929import Servant.API.Delete
3030import Servant.API.Get
31+import Servant.API.JsonBody
3132import Servant.API.Post
3233import Servant.API.Put
3334import Servant.API.QueryParam
34−import Servant.API.RQBody
3535import Servant.API.Sub
3636import Servant.API.Union
src/Servant/API/RQBody.hs → src/Servant/API/JsonBody.hsrenamed+7−7
@@ -3,7 +3,7 @@
33{-# LANGUAGE TypeOperators #-}
44{-# LANGUAGE FlexibleInstances #-}
55{-# LANGUAGE ScopedTypeVariables #-}
6−module Servant.API.RQBody where
6+module Servant.API.JsonBody where
77
88import Control.Applicative
99import Data.Aeson
@@ -15,12 +15,12 @@ import Servant.Docs
1515import Servant.Server
1616
1717-- * Request Body support
18−data RQBody a
18+data JsonBody a
1919
2020instance (FromJSON a, HasServer sublayout)
21− => HasServer (RQBody a :> sublayout) where
21+ => HasServer (JsonBody a :> sublayout) where
2222
23− type Server (RQBody a :> sublayout) =
23+ type Server (JsonBody a :> sublayout) =
2424 a -> Server sublayout
2525
2626 route Proxy subserver request respond = do
@@ -30,9 +30,9 @@ instance (FromJSON a, HasServer sublayout)
3030 Just v -> route (Proxy :: Proxy sublayout) (subserver v) request respond
3131
3232instance (ToJSON a, HasClient sublayout)
33− => HasClient (RQBody a :> sublayout) where
33+ => HasClient (JsonBody a :> sublayout) where
3434
35− type Client (RQBody a :> sublayout) =
35+ type Client (JsonBody a :> sublayout) =
3636 a -> Client sublayout
3737
3838 clientWithRoute Proxy req body =
@@ -40,7 +40,7 @@ instance (ToJSON a, HasClient sublayout)
4040 setRQBody (encode body) req
4141
4242instance (ToSample a, HasDocs sublayout)
43− => HasDocs (RQBody a :> sublayout) where
43+ => HasDocs (JsonBody a :> sublayout) where
4444
4545 docsFor Proxy (endpoint, action) =
4646 docsFor sublayoutP (endpoint, action')
test/Servant/ServerSpec.hs+3−3
@@ -22,10 +22,10 @@ import Test.Hspec.Wai
2222
2323import Servant.API.Capture
2424import Servant.API.Get
25+import Servant.API.JsonBody
2526import Servant.API.Post
2627import Servant.API.QueryParam
2728import Servant.API.Raw
28−import Servant.API.RQBody
2929import Servant.API.Sub
3030import Servant.API.Union
3131import Servant.Server
@@ -141,13 +141,13 @@ queryParamSpec = do
141141 }
142142
143143
144−type PostApi = RQBody Person :> (Post Integer)
144+type PostApi = JsonBody Person :> Post Integer
145145postApi :: Proxy PostApi
146146postApi = Proxy
147147
148148postSpec :: Spec
149149postSpec = do
150− describe "Servant.API.Post and .RQBody" $ do
150+ describe "Servant.API.Post and .JsonBody" $ do
151151 with (return (serve postApi (return . age))) $ do
152152 it "allows to POST a Person" $ do
153153 post "/" (encode alice) `shouldRespondWith` "42"{