rename JsonBody to ReqBody

This commit is contained in:
Alp Mestanogullari 2014-10-28 16:29:04 +01:00
parent 9b375b137f
commit 82a7428507
4 changed files with 12 additions and 12 deletions

View file

@ -51,7 +51,7 @@ instance ToSample Greet where
-- API specification
type TestApi =
"hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
:<|> "greet" :> JsonBody Greet :> Post Greet
:<|> "greet" :> ReqBody Greet :> Post Greet
:<|> "delete" :> Capture "greetid" Text :> Delete
testApi :: Proxy TestApi

View file

@ -22,10 +22,10 @@ library
Servant.API.Capture
Servant.API.Delete
Servant.API.Get
Servant.API.JsonBody
Servant.API.Post
Servant.API.Put
Servant.API.QueryParam
Servant.API.ReqBody
Servant.API.Raw
Servant.API.Sub
Servant.API.Union

View file

@ -9,10 +9,10 @@ module Servant.API (
-- * Accessing information from the request
-- | Capturing parts of the url path as parsed values: @'Capture'@
module Servant.API.Capture,
-- | Accessing the request body as a JSON-encoded type: @'JsonBody'@
module Servant.API.JsonBody,
-- | Retrieving parameters from the query string of the 'URI': @'QueryParam'@
module Servant.API.QueryParam,
-- | Accessing the request body as a JSON-encoded type: @'ReqBody'@
module Servant.API.ReqBody,
-- * Actual endpoints, distinguished by HTTP method
-- | GET requests
@ -28,9 +28,9 @@ module Servant.API (
import Servant.API.Capture
import Servant.API.Delete
import Servant.API.Get
import Servant.API.JsonBody
import Servant.API.Post
import Servant.API.Put
import Servant.API.QueryParam
import Servant.API.ReqBody
import Servant.API.Sub
import Servant.API.Union

View file

@ -3,7 +3,7 @@
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Servant.API.JsonBody where
module Servant.API.ReqBody where
import Control.Applicative
import Data.Aeson
@ -15,12 +15,12 @@ import Servant.Docs
import Servant.Server
-- * Request Body support
data JsonBody a
data ReqBody a
instance (FromJSON a, HasServer sublayout)
=> HasServer (JsonBody a :> sublayout) where
=> HasServer (ReqBody a :> sublayout) where
type Server (JsonBody a :> sublayout) =
type Server (ReqBody a :> sublayout) =
a -> Server sublayout
route Proxy subserver request respond = do
@ -30,9 +30,9 @@ instance (FromJSON a, HasServer sublayout)
Just v -> route (Proxy :: Proxy sublayout) (subserver v) request respond
instance (ToJSON a, HasClient sublayout)
=> HasClient (JsonBody a :> sublayout) where
=> HasClient (ReqBody a :> sublayout) where
type Client (JsonBody a :> sublayout) =
type Client (ReqBody a :> sublayout) =
a -> Client sublayout
clientWithRoute Proxy req body =
@ -40,7 +40,7 @@ instance (ToJSON a, HasClient sublayout)
setRQBody (encode body) req
instance (ToSample a, HasDocs sublayout)
=> HasDocs (JsonBody a :> sublayout) where
=> HasDocs (ReqBody a :> sublayout) where
docsFor Proxy (endpoint, action) =
docsFor sublayoutP (endpoint, action')