From 82a7428507a2b08506f49a00669b7210c2035db7 Mon Sep 17 00:00:00 2001 From: Alp Mestanogullari Date: Tue, 28 Oct 2014 16:29:04 +0100 Subject: [PATCH] rename JsonBody to ReqBody --- example/greet.hs | 2 +- servant.cabal | 2 +- src/Servant/API.hs | 6 +++--- src/Servant/API/{JsonBody.hs => ReqBody.hs} | 14 +++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) rename src/Servant/API/{JsonBody.hs => ReqBody.hs} (79%) diff --git a/example/greet.hs b/example/greet.hs index 6470dcb1..1d364515 100644 --- a/example/greet.hs +++ b/example/greet.hs @@ -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 diff --git a/servant.cabal b/servant.cabal index 7a9ab041..b5f73840 100644 --- a/servant.cabal +++ b/servant.cabal @@ -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 diff --git a/src/Servant/API.hs b/src/Servant/API.hs index f69022eb..6f841da4 100644 --- a/src/Servant/API.hs +++ b/src/Servant/API.hs @@ -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 diff --git a/src/Servant/API/JsonBody.hs b/src/Servant/API/ReqBody.hs similarity index 79% rename from src/Servant/API/JsonBody.hs rename to src/Servant/API/ReqBody.hs index afedeedc..70bba000 100644 --- a/src/Servant/API/JsonBody.hs +++ b/src/Servant/API/ReqBody.hs @@ -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')