module Network.AWS.Request.JSON
( post
) where
import Control.Applicative
import Control.Lens hiding (Action)
import Data.Aeson
import Data.Monoid
import Network.AWS.Data
import Network.AWS.Request.Internal
import Network.AWS.Types
import Network.HTTP.Types.Header
import Network.HTTP.Types.Method
post :: forall a. (AWSService (Sv a), ToQuery a, ToPath a, ToHeaders a, ToJSON a)
=> Action
-> a
-> Request a
post a x = defaultRequest x
& rqMethod .~ POST
& rqHeaders <>~ hs
& rqBody .~ toBody (toJSON x)
where
hs = toHeader hAMZTarget target
++ toHeader hContentType content
target = (\p -> p <> "." <> toBS a) <$> _svcTargetPrefix svc
content = ("application/x-amz-json-" <>) <$> _svcJSONVersion svc
svc :: Service (Sv a)
svc = service