diff --git a/servant-client-core/servant-client-core.cabal b/servant-client-core/servant-client-core.cabal index e3083239..6ea04445 100644 --- a/servant-client-core/servant-client-core.cabal +++ b/servant-client-core/servant-client-core.cabal @@ -9,6 +9,7 @@ author: Servant Contributors maintainer: haskell-servant-maintainers@googlegroups.com homepage: http://haskell-servant.readthedocs.org/ bug-reports: http://github.com/haskell-servant/servant/issues +cabal-version: >=1.10 -- copyright: category: Web build-type: Simple @@ -19,15 +20,34 @@ extra-source-files: source-repository head type: git location: http://github.com/haskell-servant/servant.git -cabal-version: >=1.10 library exposed-modules: + Servant.Client.Core + Servant.Client.Core.Internal.Auth + Servant.Client.Core.Internal.BaseUrl + Servant.Client.Core.Internal.BasicAuth + Servant.Client.Core.Internal.Class + Servant.Client.Core.Internal.Generic + Servant.Client.Core.Internal.Request build-depends: base >= 4.7 && < 4.11 , base-compat >= 0.9.1 && < 0.10 + , base64-bytestring >= 1.0.0.1 && < 1.1 + , bytestring >= 0.10 && < 0.11 + , containers >= 0.5 && < 0.6 + , exceptions >= 0.8 && < 0.9 + , generics-sop >= 0.1.0.0 && < 0.4 + , http-api-data >= 0.3.6 && < 0.4 + , http-media >= 0.6.2 && < 0.8 + , http-types >= 0.8.6 && < 0.10 + , network-uri >= 2.6 && < 2.7 + , safe >= 0.3.9 && < 0.4 + , servant == 0.11.* + , text >= 1.2 && < 1.3 hs-source-dirs: src default-language: Haskell2010 + include-dirs: include test-suite spec type: exitcode-stdio-1.0 diff --git a/servant-client/src/Servant/Client.hs b/servant-client-core/src/Servant/Client/Core.hs similarity index 99% rename from servant-client/src/Servant/Client.hs rename to servant-client-core/src/Servant/Client/Core.hs index beeb589b..6d1b014d 100644 --- a/servant-client/src/Servant/Client.hs +++ b/servant-client-core/src/Servant/Client/Core.hs @@ -16,7 +16,7 @@ -- | This module provides 'client' which can automatically generate -- querying functions for each endpoint just from the type representing your -- API. -module Servant.Client +module Servant.Client.Core ( AuthClientData , AuthenticateReq(..) , client diff --git a/servant-client-core/src/Servant/Client/Core/Internal/Auth.hs b/servant-client-core/src/Servant/Client/Core/Internal/Auth.hs index b9bb70e6..9640bfbe 100644 --- a/servant-client-core/src/Servant/Client/Core/Internal/Auth.hs +++ b/servant-client-core/src/Servant/Client/Core/Internal/Auth.hs @@ -4,13 +4,9 @@ -- | Authentication for clients -module Servant.Client.Experimental.Auth ( - AuthenticateReq(AuthenticateReq, unAuthReq) - , AuthClientData - , mkAuthenticateReq - ) where +module Servant.Client.Core.Internal.Auth where -import Servant.Common.Req (Request) +import Servant.Client.Core.Internal.Request (Request) -- | For a resource protected by authentication (e.g. AuthProtect), we need -- to provide the client with some data used to add authentication data diff --git a/servant-client-core/src/Servant/Client/Core/Internal/BaseUrl.hs b/servant-client-core/src/Servant/Client/Core/Internal/BaseUrl.hs index 5c3c190a..9443035d 100644 --- a/servant-client-core/src/Servant/Client/Core/Internal/BaseUrl.hs +++ b/servant-client-core/src/Servant/Client/Core/Internal/BaseUrl.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE ViewPatterns #-} -module Servant.Common.BaseUrl ( +module Servant.Client.Core.Internal.BaseUrl ( -- * types BaseUrl (..) , InvalidBaseUrlException diff --git a/servant-client-core/src/Servant/Client/Core/Internal/BasicAuth.hs b/servant-client-core/src/Servant/Client/Core/Internal/BasicAuth.hs index df5cc66a..978ef2b3 100644 --- a/servant-client-core/src/Servant/Client/Core/Internal/BasicAuth.hs +++ b/servant-client-core/src/Servant/Client/Core/Internal/BasicAuth.hs @@ -4,14 +4,12 @@ -- | Basic Authentication for clients -module Servant.Common.BasicAuth ( - basicAuthReq - ) where +module Servant.Client.Core.Internal.BasicAuth where import Data.ByteString.Base64 (encode) import Data.Monoid ((<>)) import Data.Text.Encoding (decodeUtf8) -import Servant.Common.Req (addHeader, Request) +import Servant.Client.Core.Internal.Request (addHeader, Request) import Servant.API.BasicAuth (BasicAuthData(BasicAuthData)) -- | Authenticate a request using Basic Authentication diff --git a/servant-client-core/src/Servant/Client/Core/Internal/Class.hs b/servant-client-core/src/Servant/Client/Core/Internal/Class.hs index 38dd3459..cea567f9 100644 --- a/servant-client-core/src/Servant/Client/Core/Internal/Class.hs +++ b/servant-client-core/src/Servant/Client/Core/Internal/Class.hs @@ -1,10 +1,10 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-| Types for possible backends to run client-side `Request` queries -} -module Servant.Client.Class where +module Servant.Client.Core.Internal.Class where import Data.Proxy import Network.HTTP.Types -import Servant.Common.Req (Request, Response) +import Servant.Client.Core.Internal.Request (Request, Response) class (Monad m) => RunClient m ct where runRequest :: Proxy ct diff --git a/servant-client-core/src/Servant/Client/Core/Internal/Generic.hs b/servant-client-core/src/Servant/Client/Core/Internal/Generic.hs index 425e7839..c2f5a662 100644 --- a/servant-client-core/src/Servant/Client/Core/Internal/Generic.hs +++ b/servant-client-core/src/Servant/Client/Core/Internal/Generic.hs @@ -10,7 +10,7 @@ #include "overlapping-compat.h" -module Servant.Client.Generic +module Servant.Client.Core.Internal.Generic ( ClientLike(..) , genericMkClientL , genericMkClientP @@ -18,7 +18,6 @@ module Servant.Client.Generic import Generics.SOP (Code, Generic, I(..), NP(..), NS(Z), SOP(..), to) import Servant.API ((:<|>)(..)) -import Servant.Client (ClientM) -- | This class allows us to match client structure with client functions -- produced with 'client' without explicit pattern-matching. @@ -111,7 +110,7 @@ instance ClientLike client custom => ClientLike (a -> client) (a -> custom) where mkClient c = mkClient . c -instance ClientLike (ClientM a) (ClientM a) where +instance ClientLike (m a) (m a) where mkClient = id -- | Match client structure with client functions, regarding left-nested API clients diff --git a/servant-client-core/src/Servant/Client/Core/Internal/Request.hs b/servant-client-core/src/Servant/Client/Core/Internal/Request.hs index 73b8a43f..8cdf79b7 100644 --- a/servant-client-core/src/Servant/Client/Core/Internal/Request.hs +++ b/servant-client-core/src/Servant/Client/Core/Internal/Request.hs @@ -7,7 +7,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} -module Servant.Common.Request where +module Servant.Client.Core.Internal.Request where import Prelude () import Prelude.Compat @@ -16,13 +16,12 @@ import qualified Data.ByteString.Builder as Builder import qualified Data.ByteString.Lazy as LBS import Data.Semigroup ((<>)) import qualified Data.Sequence as Seq -import Data.String.Conversions (cs) import Data.Text (Text) import Data.Typeable (Typeable) import GHC.Generics (Generic) import Network.HTTP.Media (MediaType) import Network.HTTP.Types (Header, HeaderName, HttpVersion, - Method, QueryItem, Status, http11) + QueryItem, Status, http11) import Web.HttpApiData (ToHttpApiData, toEncodedUrlPiece, toHeader) @@ -126,21 +125,22 @@ setRequestBody b t req = req { requestBody = Just (b, t) } {-toProperHeader (name, val) =-} {-(fromString name, encodeUtf8 val)-} -#if !MIN_VERSION_http_client(0,4,30) --- 'parseRequest' is introduced in http-client-0.4.30 --- it differs from 'parseUrl', by not throwing exceptions on non-2xx http statuses --- --- See for implementations: --- http://hackage.haskell.org/package/http-client-0.4.30/docs/src/Network-HTTP-Client-Request.html#parseRequest --- http://hackage.haskell.org/package/http-client-0.5.0/docs/src/Network-HTTP-Client-Request.html#parseRequest -parseRequest :: MonadThrow m => String -> m Request -parseRequest url = liftM disableStatusCheck (parseUrl url) - where - disableStatusCheck req = req { checkStatus = \ _status _headers _cookies -> Nothing } -#endif + + {- #if !MIN_VERSION_http_client(0,4,30)-} + {--- 'parseRequest' is introduced in http-client-0.4.30-} + {--- it differs from 'parseUrl', by not throwing exceptions on non-2xx http statuses-} + {----} + {--- See for implementations:-} + {--- http://hackage.haskell.org/package/http-client-0.4.30/docs/src/Network-HTTP-Client-Request.html#parseRequest-} + {--- http://hackage.haskell.org/package/http-client-0.5.0/docs/src/Network-HTTP-Client-Request.html#parseRequest-} + {-parseRequest :: MonadThrow m => String -> m Request-} + {-parseRequest url = liftM disableStatusCheck (parseUrl url)-} + {-where-} + {-disableStatusCheck req = req { checkStatus = \ _status _headers _cookies -> Nothing }-} + {- #endif-} --- * performing requests + {--- * performing requests-} -displayHttpRequest :: Method -> String -displayHttpRequest httpmethod = "HTTP " ++ cs httpmethod ++ " request" + {-displayHttpRequest :: Method -> String-} + {-displayHttpRequest httpmethod = "HTTP " ++ cs httpmethod ++ " request"-} diff --git a/servant-client/servant-client.cabal b/servant-client/servant-client.cabal index 7d52d1c5..4015d683 100644 --- a/servant-client/servant-client.cabal +++ b/servant-client/servant-client.cabal @@ -42,23 +42,10 @@ library , base-compat >= 0.9.1 && < 0.10 , aeson >= 0.7 && < 1.3 , attoparsec >= 0.12 && < 0.14 - , base64-bytestring >= 1.0.0.1 && < 1.1 - , bytestring >= 0.10 && < 0.11 - , containers >= 0.5 && < 0.6 - , exceptions >= 0.8 && < 0.9 - , generics-sop >= 0.1.0.0 && < 0.4 - , http-api-data >= 0.3.6 && < 0.4 , http-client >= 0.4.18.1 && < 0.6 , http-client-tls >= 0.2.2 && < 0.4 - , http-media >= 0.6.2 && < 0.8 - , http-types >= 0.8.6 && < 0.10 , monad-control >= 1.0.0.4 && < 1.1 - , network-uri >= 2.6 && < 2.7 - , safe >= 0.3.9 && < 0.4 , semigroupoids >= 4.3 && < 5.3 - , servant == 0.11.* - , string-conversions >= 0.3 && < 0.5 - , text >= 1.2 && < 1.3 , transformers >= 0.3 && < 0.6 , transformers-base >= 0.4.4 && < 0.5 , transformers-compat >= 0.4 && < 0.6 diff --git a/stack-ghc-7.10.3.yaml b/stack-ghc-7.10.3.yaml index fb18aac7..e1f14b91 100644 --- a/stack-ghc-7.10.3.yaml +++ b/stack-ghc-7.10.3.yaml @@ -2,6 +2,7 @@ flags: {} packages: - servant/ - servant-client/ +- servant-client-core/ - servant-docs/ - servant-foreign/ - servant-server/ diff --git a/stack-ghc-7.8.4.yaml b/stack-ghc-7.8.4.yaml index 01bb6420..479a6d20 100644 --- a/stack-ghc-7.8.4.yaml +++ b/stack-ghc-7.8.4.yaml @@ -2,6 +2,7 @@ flags: {} packages: - servant/ - servant-client/ +- servant-client-core/ - servant-docs/ - servant-foreign/ - servant-server/ diff --git a/stack-ghc-8.2.1.yaml b/stack-ghc-8.2.1.yaml index c1a64f37..926f72cf 100644 --- a/stack-ghc-8.2.1.yaml +++ b/stack-ghc-8.2.1.yaml @@ -1,6 +1,7 @@ resolver: nightly-2017-09-01 packages: - servant-client/ +- servant-client-core/ - servant-docs/ - servant-foreign/ - servant-server/ diff --git a/stack.yaml b/stack.yaml index 62ff4f2b..e283f7fd 100644 --- a/stack.yaml +++ b/stack.yaml @@ -2,6 +2,7 @@ resolver: nightly-2017-04-01 packages: - servant/ - servant-client/ +- servant-client-core/ - servant-docs/ - servant-foreign/ - servant-server/