rename JsonBody to ReqBody
This commit is contained in:
parent
9b375b137f
commit
82a7428507
4 changed files with 12 additions and 12 deletions
|
@ -51,7 +51,7 @@ instance ToSample Greet where
|
||||||
-- API specification
|
-- API specification
|
||||||
type TestApi =
|
type TestApi =
|
||||||
"hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
|
"hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
|
||||||
:<|> "greet" :> JsonBody Greet :> Post Greet
|
:<|> "greet" :> ReqBody Greet :> Post Greet
|
||||||
:<|> "delete" :> Capture "greetid" Text :> Delete
|
:<|> "delete" :> Capture "greetid" Text :> Delete
|
||||||
|
|
||||||
testApi :: Proxy TestApi
|
testApi :: Proxy TestApi
|
||||||
|
|
|
@ -22,10 +22,10 @@ library
|
||||||
Servant.API.Capture
|
Servant.API.Capture
|
||||||
Servant.API.Delete
|
Servant.API.Delete
|
||||||
Servant.API.Get
|
Servant.API.Get
|
||||||
Servant.API.JsonBody
|
|
||||||
Servant.API.Post
|
Servant.API.Post
|
||||||
Servant.API.Put
|
Servant.API.Put
|
||||||
Servant.API.QueryParam
|
Servant.API.QueryParam
|
||||||
|
Servant.API.ReqBody
|
||||||
Servant.API.Raw
|
Servant.API.Raw
|
||||||
Servant.API.Sub
|
Servant.API.Sub
|
||||||
Servant.API.Union
|
Servant.API.Union
|
||||||
|
|
|
@ -9,10 +9,10 @@ module Servant.API (
|
||||||
-- * Accessing information from the request
|
-- * Accessing information from the request
|
||||||
-- | Capturing parts of the url path as parsed values: @'Capture'@
|
-- | Capturing parts of the url path as parsed values: @'Capture'@
|
||||||
module Servant.API.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'@
|
-- | Retrieving parameters from the query string of the 'URI': @'QueryParam'@
|
||||||
module Servant.API.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
|
-- * Actual endpoints, distinguished by HTTP method
|
||||||
-- | GET requests
|
-- | GET requests
|
||||||
|
@ -28,9 +28,9 @@ module Servant.API (
|
||||||
import Servant.API.Capture
|
import Servant.API.Capture
|
||||||
import Servant.API.Delete
|
import Servant.API.Delete
|
||||||
import Servant.API.Get
|
import Servant.API.Get
|
||||||
import Servant.API.JsonBody
|
|
||||||
import Servant.API.Post
|
import Servant.API.Post
|
||||||
import Servant.API.Put
|
import Servant.API.Put
|
||||||
import Servant.API.QueryParam
|
import Servant.API.QueryParam
|
||||||
|
import Servant.API.ReqBody
|
||||||
import Servant.API.Sub
|
import Servant.API.Sub
|
||||||
import Servant.API.Union
|
import Servant.API.Union
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
{-# LANGUAGE TypeOperators #-}
|
{-# LANGUAGE TypeOperators #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
{-# LANGUAGE ScopedTypeVariables #-}
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
module Servant.API.JsonBody where
|
module Servant.API.ReqBody where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
|
@ -15,12 +15,12 @@ import Servant.Docs
|
||||||
import Servant.Server
|
import Servant.Server
|
||||||
|
|
||||||
-- * Request Body support
|
-- * Request Body support
|
||||||
data JsonBody a
|
data ReqBody a
|
||||||
|
|
||||||
instance (FromJSON a, HasServer sublayout)
|
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
|
a -> Server sublayout
|
||||||
|
|
||||||
route Proxy subserver request respond = do
|
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
|
Just v -> route (Proxy :: Proxy sublayout) (subserver v) request respond
|
||||||
|
|
||||||
instance (ToJSON a, HasClient sublayout)
|
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
|
a -> Client sublayout
|
||||||
|
|
||||||
clientWithRoute Proxy req body =
|
clientWithRoute Proxy req body =
|
||||||
|
@ -40,7 +40,7 @@ instance (ToJSON a, HasClient sublayout)
|
||||||
setRQBody (encode body) req
|
setRQBody (encode body) req
|
||||||
|
|
||||||
instance (ToSample a, HasDocs sublayout)
|
instance (ToSample a, HasDocs sublayout)
|
||||||
=> HasDocs (JsonBody a :> sublayout) where
|
=> HasDocs (ReqBody a :> sublayout) where
|
||||||
|
|
||||||
docsFor Proxy (endpoint, action) =
|
docsFor Proxy (endpoint, action) =
|
||||||
docsFor sublayoutP (endpoint, action')
|
docsFor sublayoutP (endpoint, action')
|
Loading…
Reference in a new issue