-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | automatical derivation of querying functions for servant webservices -- -- This library lets you derive automatically Haskell functions that let -- you query each endpoint of a servant webservice. -- -- See the client section of the tutorial. -- -- CHANGELOG @package servant-client @version 0.8 module Servant.Common.BaseUrl -- | Simple data type to represent the target of HTTP requests for -- servant's automatically-generated clients. data BaseUrl BaseUrl :: Scheme -> String -> Int -> String -> BaseUrl -- | URI scheme to use [baseUrlScheme] :: BaseUrl -> Scheme -- | host (eg "haskell.org") [baseUrlHost] :: BaseUrl -> String -- | port (eg 80) [baseUrlPort] :: BaseUrl -> Int -- | path (eg "ab/c") [baseUrlPath] :: BaseUrl -> String data InvalidBaseUrlException -- | URI scheme to use data Scheme -- | http:// Http :: Scheme -- | https:// Https :: Scheme parseBaseUrl :: MonadThrow m => String -> m BaseUrl showBaseUrl :: BaseUrl -> String instance GHC.Show.Show Servant.Common.BaseUrl.InvalidBaseUrlException instance GHC.Generics.Generic Servant.Common.BaseUrl.BaseUrl instance GHC.Classes.Ord Servant.Common.BaseUrl.BaseUrl instance GHC.Show.Show Servant.Common.BaseUrl.BaseUrl instance GHC.Generics.Generic Servant.Common.BaseUrl.Scheme instance GHC.Classes.Ord Servant.Common.BaseUrl.Scheme instance GHC.Classes.Eq Servant.Common.BaseUrl.Scheme instance GHC.Show.Show Servant.Common.BaseUrl.Scheme instance GHC.Classes.Eq Servant.Common.BaseUrl.BaseUrl instance GHC.Exception.Exception Servant.Common.BaseUrl.InvalidBaseUrlException module Servant.Common.Req data ServantError FailureResponse :: Status -> MediaType -> ByteString -> ServantError [responseStatus] :: ServantError -> Status [responseContentType] :: ServantError -> MediaType [responseBody] :: ServantError -> ByteString DecodeFailure :: String -> MediaType -> ByteString -> ServantError [decodeError] :: ServantError -> String [responseContentType] :: ServantError -> MediaType [responseBody] :: ServantError -> ByteString UnsupportedContentType :: MediaType -> ByteString -> ServantError [responseContentType] :: ServantError -> MediaType [responseBody] :: ServantError -> ByteString InvalidContentTypeHeader :: ByteString -> ByteString -> ServantError [responseContentTypeHeader] :: ServantError -> ByteString [responseBody] :: ServantError -> ByteString ConnectionError :: SomeException -> ServantError [connectionError] :: ServantError -> SomeException data Req Req :: String -> QueryText -> Maybe (ByteString, MediaType) -> [MediaType] -> [(String, Text)] -> Req [reqPath] :: Req -> String [qs] :: Req -> QueryText [reqBody] :: Req -> Maybe (ByteString, MediaType) [reqAccept] :: Req -> [MediaType] [headers] :: Req -> [(String, Text)] defReq :: Req appendToPath :: String -> Req -> Req appendToQueryString :: Text -> Maybe Text -> Req -> Req addHeader :: ToHttpApiData a => String -> a -> Req -> Req setRQBody :: ByteString -> MediaType -> Req -> Req reqToRequest :: (Functor m, MonadThrow m) => Req -> BaseUrl -> m Request displayHttpRequest :: Method -> String type ClientM = ExceptT ServantError IO performRequest :: Method -> Req -> Manager -> BaseUrl -> ClientM (Int, ByteString, MediaType, [Header], Response ByteString) disableStatusCheck :: Request -> Request performRequestCT :: MimeUnrender ct result => Proxy ct -> Method -> Req -> Manager -> BaseUrl -> ClientM ([Header], result) performRequestNoBody :: Method -> Req -> Manager -> BaseUrl -> ClientM [Header] catchConnectionError :: IO a -> IO (Either ServantError a) instance GHC.Show.Show Servant.Common.Req.ServantError instance GHC.Classes.Eq Servant.Common.Req.ServantError instance GHC.Exception.Exception Servant.Common.Req.ServantError -- | Authentication for clients module Servant.Client.Experimental.Auth -- | For better type inference and to avoid usage of a data family, we -- newtype wrap the combination of some AuthClientData and a -- function to add authentication data to a request -- -- NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE newtype AuthenticateReq a AuthenticateReq :: (AuthClientData a, AuthClientData a -> Req -> Req) -> AuthenticateReq a [unAuthReq] :: AuthenticateReq a -> (AuthClientData a, AuthClientData a -> Req -> Req) -- | For a resource protected by authentication (e.g. AuthProtect), we need -- to provide the client with some data used to add authentication data -- to a request -- -- NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE -- | Handy helper to avoid wrapping datatypes in tuples everywhere. -- -- NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE mkAuthenticateReq :: AuthClientData a -> (AuthClientData a -> Req -> Req) -> AuthenticateReq a -- | Basic Authentication for clients module Servant.Common.BasicAuth -- | Authenticate a request using Basic Authentication basicAuthReq :: BasicAuthData -> Req -> Req -- | This module provides client which can automatically generate -- querying functions for each endpoint just from the type representing -- your API. module Servant.Client -- | For a resource protected by authentication (e.g. AuthProtect), we need -- to provide the client with some data used to add authentication data -- to a request -- -- NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE -- | For better type inference and to avoid usage of a data family, we -- newtype wrap the combination of some AuthClientData and a -- function to add authentication data to a request -- -- NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE newtype AuthenticateReq a AuthenticateReq :: (AuthClientData a, AuthClientData a -> Req -> Req) -> AuthenticateReq a [unAuthReq] :: AuthenticateReq a -> (AuthClientData a, AuthClientData a -> Req -> Req) -- | client allows you to produce operations to query an API from a -- client. -- --
-- type MyApi = "books" :> Get '[JSON] [Book] -- GET /books -- :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book -- POST /books -- -- myApi :: Proxy MyApi -- myApi = Proxy -- -- getAllBooks :: Manager -> BaseUrl -> ClientM [Book] -- postNewBook :: Book -> Manager -> BaseUrl -> ClientM Book -- (getAllBooks :<|> postNewBook) = client myApi --client :: HasClient api => Proxy api -> Client api -- | This class lets us define how each API combinator influences the -- creation of an HTTP request. It's mostly an internal class, you can -- just use client. class HasClient api where type Client api :: * where { type family Client api :: *; } clientWithRoute :: HasClient api => Proxy api -> Req -> Client api type ClientM = ExceptT ServantError IO -- | Handy helper to avoid wrapping datatypes in tuples everywhere. -- -- NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE mkAuthenticateReq :: AuthClientData a -> (AuthClientData a -> Req -> Req) -> AuthenticateReq a data ServantError FailureResponse :: Status -> MediaType -> ByteString -> ServantError [responseStatus] :: ServantError -> Status [responseContentType] :: ServantError -> MediaType [responseBody] :: ServantError -> ByteString DecodeFailure :: String -> MediaType -> ByteString -> ServantError [decodeError] :: ServantError -> String [responseContentType] :: ServantError -> MediaType [responseBody] :: ServantError -> ByteString UnsupportedContentType :: MediaType -> ByteString -> ServantError [responseContentType] :: ServantError -> MediaType [responseBody] :: ServantError -> ByteString InvalidContentTypeHeader :: ByteString -> ByteString -> ServantError [responseContentTypeHeader] :: ServantError -> ByteString [responseBody] :: ServantError -> ByteString ConnectionError :: SomeException -> ServantError [connectionError] :: ServantError -> SomeException instance (Servant.Client.HasClient a, Servant.Client.HasClient b) => Servant.Client.HasClient (a Servant.API.Alternative.:<|> b) instance forall k1 (capture :: GHC.Types.Symbol) a (api :: k1). (GHC.TypeLits.KnownSymbol capture, Web.HttpApiData.Internal.ToHttpApiData a, Servant.Client.HasClient api) => Servant.Client.HasClient (Servant.API.Capture.Capture capture a Servant.API.Sub.:> api) instance forall k1 ct a (method :: k1) (cts' :: [GHC.Types.*]) (cts :: [GHC.Types.*]) (status :: GHC.Types.Nat). (Servant.API.ContentTypes.MimeUnrender ct a, Servant.API.Verbs.ReflectMethod method, cts' ~ (ct : cts)) => Servant.Client.HasClient (Servant.API.Verbs.Verb method status cts' a) instance forall k1 (method :: k1) (status :: GHC.Types.Nat) (cts :: [GHC.Types.*]). Servant.API.Verbs.ReflectMethod method => Servant.Client.HasClient (Servant.API.Verbs.Verb method status cts Servant.API.ContentTypes.NoContent) instance forall k1 ct a (ls :: [*]) (method :: k1) (cts' :: [GHC.Types.*]) (cts :: [GHC.Types.*]) (status :: GHC.Types.Nat). (Servant.API.ContentTypes.MimeUnrender ct a, Servant.API.ResponseHeaders.BuildHeadersTo ls, Servant.API.Verbs.ReflectMethod method, cts' ~ (ct : cts)) => Servant.Client.HasClient (Servant.API.Verbs.Verb method status cts' (Servant.API.ResponseHeaders.Headers ls a)) instance forall k1 (ls :: [*]) (method :: k1) (status :: GHC.Types.Nat) (cts :: [GHC.Types.*]). (Servant.API.ResponseHeaders.BuildHeadersTo ls, Servant.API.Verbs.ReflectMethod method) => Servant.Client.HasClient (Servant.API.Verbs.Verb method status cts (Servant.API.ResponseHeaders.Headers ls Servant.API.ContentTypes.NoContent)) instance forall k1 (sym :: GHC.Types.Symbol) a (api :: k1). (GHC.TypeLits.KnownSymbol sym, Web.HttpApiData.Internal.ToHttpApiData a, Servant.Client.HasClient api) => Servant.Client.HasClient (Servant.API.Header.Header sym a Servant.API.Sub.:> api) instance forall k1 (api :: k1). Servant.Client.HasClient api => Servant.Client.HasClient (Network.HTTP.Types.Version.HttpVersion Servant.API.Sub.:> api) instance forall k1 (sym :: GHC.Types.Symbol) a (api :: k1). (GHC.TypeLits.KnownSymbol sym, Web.HttpApiData.Internal.ToHttpApiData a, Servant.Client.HasClient api) => Servant.Client.HasClient (Servant.API.QueryParam.QueryParam sym a Servant.API.Sub.:> api) instance forall k1 (sym :: GHC.Types.Symbol) a (api :: k1). (GHC.TypeLits.KnownSymbol sym, Web.HttpApiData.Internal.ToHttpApiData a, Servant.Client.HasClient api) => Servant.Client.HasClient (Servant.API.QueryParam.QueryParams sym a Servant.API.Sub.:> api) instance forall k1 (sym :: GHC.Types.Symbol) (api :: k1). (GHC.TypeLits.KnownSymbol sym, Servant.Client.HasClient api) => Servant.Client.HasClient (Servant.API.QueryParam.QueryFlag sym Servant.API.Sub.:> api) instance Servant.Client.HasClient Servant.API.Raw.Raw instance forall k1 ct a (api :: k1) (cts :: [GHC.Types.*]). (Servant.API.ContentTypes.MimeRender ct a, Servant.Client.HasClient api) => Servant.Client.HasClient (Servant.API.ReqBody.ReqBody (ct : cts) a Servant.API.Sub.:> api) instance forall k1 (path :: GHC.Types.Symbol) (api :: k1). (GHC.TypeLits.KnownSymbol path, Servant.Client.HasClient api) => Servant.Client.HasClient (path Servant.API.Sub.:> api) instance forall k1 (api :: k1). Servant.Client.HasClient api => Servant.Client.HasClient (Data.Vault.Lazy.Vault Servant.API.Sub.:> api) instance forall k1 (api :: k1). Servant.Client.HasClient api => Servant.Client.HasClient (Servant.API.RemoteHost.RemoteHost Servant.API.Sub.:> api) instance forall k1 (api :: k1). Servant.Client.HasClient api => Servant.Client.HasClient (Servant.API.IsSecure.IsSecure Servant.API.Sub.:> api) instance Servant.Client.HasClient subapi => Servant.Client.HasClient (Servant.API.WithNamedContext.WithNamedContext name context subapi) instance forall k1 k (api :: k1) (tag :: k). Servant.Client.HasClient api => Servant.Client.HasClient (Servant.API.Experimental.Auth.AuthProtect tag Servant.API.Sub.:> api) instance forall k1 (api :: k1) (realm :: GHC.Types.Symbol) usr. Servant.Client.HasClient api => Servant.Client.HasClient (Servant.API.BasicAuth.BasicAuth realm usr Servant.API.Sub.:> api)