module Network.Api.Support.Core (
runRequest
, runRequest'
) where
import Network.Api.Support.Request
import Network.Api.Support.Response
import Control.Monad
import Data.Text
import Data.Monoid
import Network.HTTP.Client
import Network.HTTP.Types
runRequest ::
ManagerSettings
-> StdMethod
-> Text
-> RequestTransformer
-> Responder b
-> IO b
runRequest settings stdmethod url transform =
runRequest' settings url (transform <> setMethod (renderStdMethod stdmethod))
runRequest' ::
ManagerSettings
-> Text
-> RequestTransformer
-> Responder b
-> IO b
runRequest' settings url transform responder =
do url' <- parseUrl $ unpack url
let url'' = url' { checkStatus = const . const . const $ Nothing }
let req = appEndo transform url''
liftM (responder req) . withManager settings . httpLbs $ req