on master help sign in
More reorganization
35599d8Julian K. Arni
servant-client-core/servant-client-core.cabal+21−1
@@ -9,6 +9,7 @@ author: Servant Contributors
9maintainer: haskell-servant-maintainers@googlegroups.com
9maintainer: haskell-servant-maintainers@googlegroups.com
10homepage: http://haskell-servant.readthedocs.org/
10homepage: http://haskell-servant.readthedocs.org/
11bug-reports: http://github.com/haskell-servant/servant/issues
11bug-reports: http://github.com/haskell-servant/servant/issues
12+cabal-version: >=1.10
12-- copyright:
13-- copyright:
13category: Web
14category: Web
14build-type: Simple
15build-type: Simple
@@ -19,15 +20,34 @@ extra-source-files:
19source-repository head
20source-repository head
20 type: git
21 type: git
21 location: http://github.com/haskell-servant/servant.git
22 location: http://github.com/haskell-servant/servant.git
22−cabal-version: >=1.10
23
23
24library
24library
25 exposed-modules:
25 exposed-modules:
26+ Servant.Client.Core
27+ Servant.Client.Core.Internal.Auth
28+ Servant.Client.Core.Internal.BaseUrl
29+ Servant.Client.Core.Internal.BasicAuth
30+ Servant.Client.Core.Internal.Class
31+ Servant.Client.Core.Internal.Generic
32+ Servant.Client.Core.Internal.Request
26 build-depends:
33 build-depends:
27 base >= 4.7 && < 4.11
34 base >= 4.7 && < 4.11
28 , base-compat >= 0.9.1 && < 0.10
35 , base-compat >= 0.9.1 && < 0.10
36+ , base64-bytestring >= 1.0.0.1 && < 1.1
37+ , bytestring >= 0.10 && < 0.11
38+ , containers >= 0.5 && < 0.6
39+ , exceptions >= 0.8 && < 0.9
40+ , generics-sop >= 0.1.0.0 && < 0.4
41+ , http-api-data >= 0.3.6 && < 0.4
42+ , http-media >= 0.6.2 && < 0.8
43+ , http-types >= 0.8.6 && < 0.10
44+ , network-uri >= 2.6 && < 2.7
45+ , safe >= 0.3.9 && < 0.4
46+ , servant == 0.11.*
47+ , text >= 1.2 && < 1.3
29 hs-source-dirs: src
48 hs-source-dirs: src
30 default-language: Haskell2010
49 default-language: Haskell2010
50+ include-dirs: include
31
51
32test-suite spec
52test-suite spec
33 type: exitcode-stdio-1.0
53 type: exitcode-stdio-1.0
servant-client/src/Servant/Client.hs → servant-client-core/src/Servant/Client/Core.hsrenamed+1−1
@@ -16,7 +16,7 @@
16-- | This module provides 'client' which can automatically generate
16-- | This module provides 'client' which can automatically generate
17-- querying functions for each endpoint just from the type representing your
17-- querying functions for each endpoint just from the type representing your
18-- API.
18-- API.
19−module Servant.Client
19+module Servant.Client.Core
20 ( AuthClientData
20 ( AuthClientData
21 , AuthenticateReq(..)
21 , AuthenticateReq(..)
22 , client
22 , client
servant-client-core/src/Servant/Client/Core/Internal/Auth.hs+2−6
@@ -4,13 +4,9 @@
4
4
5-- | Authentication for clients
5-- | Authentication for clients
6
6
7−module Servant.Client.Experimental.Auth (
7+module Servant.Client.Core.Internal.Auth where
8− AuthenticateReq(AuthenticateReq, unAuthReq)
9− , AuthClientData
10− , mkAuthenticateReq
11− ) where
12
8
13−import Servant.Common.Req (Request)
9+import Servant.Client.Core.Internal.Request (Request)
14
10
15-- | For a resource protected by authentication (e.g. AuthProtect), we need
11-- | For a resource protected by authentication (e.g. AuthProtect), we need
16-- to provide the client with some data used to add authentication data
12-- to provide the client with some data used to add authentication data
servant-client-core/src/Servant/Client/Core/Internal/BaseUrl.hs+1−1
@@ -1,7 +1,7 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE ViewPatterns #-}
3{-# LANGUAGE ViewPatterns #-}
4−module Servant.Common.BaseUrl (
4+module Servant.Client.Core.Internal.BaseUrl (
5 -- * types
5 -- * types
6 BaseUrl (..)
6 BaseUrl (..)
7 , InvalidBaseUrlException
7 , InvalidBaseUrlException
servant-client-core/src/Servant/Client/Core/Internal/BasicAuth.hs+2−4
@@ -4,14 +4,12 @@
4
4
5-- | Basic Authentication for clients
5-- | Basic Authentication for clients
6
6
7−module Servant.Common.BasicAuth (
7+module Servant.Client.Core.Internal.BasicAuth where
8− basicAuthReq
9− ) where
10
8
11import Data.ByteString.Base64 (encode)
9import Data.ByteString.Base64 (encode)
12import Data.Monoid ((<>))
10import Data.Monoid ((<>))
13import Data.Text.Encoding (decodeUtf8)
11import Data.Text.Encoding (decodeUtf8)
14−import Servant.Common.Req (addHeader, Request)
12+import Servant.Client.Core.Internal.Request (addHeader, Request)
15import Servant.API.BasicAuth (BasicAuthData(BasicAuthData))
13import Servant.API.BasicAuth (BasicAuthData(BasicAuthData))
16
14
17-- | Authenticate a request using Basic Authentication
15-- | Authenticate a request using Basic Authentication
servant-client-core/src/Servant/Client/Core/Internal/Class.hs+2−2
@@ -1,10 +1,10 @@
1{-# LANGUAGE MultiParamTypeClasses #-}
1{-# LANGUAGE MultiParamTypeClasses #-}
2{-| Types for possible backends to run client-side `Request` queries -}
2{-| Types for possible backends to run client-side `Request` queries -}
3−module Servant.Client.Class where
3+module Servant.Client.Core.Internal.Class where
4
4
5import Data.Proxy
5import Data.Proxy
6import Network.HTTP.Types
6import Network.HTTP.Types
7−import Servant.Common.Req (Request, Response)
7+import Servant.Client.Core.Internal.Request (Request, Response)
8
8
9class (Monad m) => RunClient m ct where
9class (Monad m) => RunClient m ct where
10 runRequest :: Proxy ct
10 runRequest :: Proxy ct
servant-client-core/src/Servant/Client/Core/Internal/Generic.hs+2−3
@@ -10,7 +10,7 @@
10
10
11#include "overlapping-compat.h"
11#include "overlapping-compat.h"
12
12
13−module Servant.Client.Generic
13+module Servant.Client.Core.Internal.Generic
14 ( ClientLike(..)
14 ( ClientLike(..)
15 , genericMkClientL
15 , genericMkClientL
16 , genericMkClientP
16 , genericMkClientP
@@ -18,7 +18,6 @@ module Servant.Client.Generic
18
18
19import Generics.SOP (Code, Generic, I(..), NP(..), NS(Z), SOP(..), to)
19import Generics.SOP (Code, Generic, I(..), NP(..), NS(Z), SOP(..), to)
20import Servant.API ((:<|>)(..))
20import Servant.API ((:<|>)(..))
21−import Servant.Client (ClientM)
22
21
23-- | This class allows us to match client structure with client functions
22-- | This class allows us to match client structure with client functions
24-- produced with 'client' without explicit pattern-matching.
23-- produced with 'client' without explicit pattern-matching.
@@ -111,7 +110,7 @@ instance ClientLike client custom
111 => ClientLike (a -> client) (a -> custom) where
110 => ClientLike (a -> client) (a -> custom) where
112 mkClient c = mkClient . c
111 mkClient c = mkClient . c
113
112
114−instance ClientLike (ClientM a) (ClientM a) where
113+instance ClientLike (m a) (m a) where
115 mkClient = id
114 mkClient = id
116
115
117-- | Match client structure with client functions, regarding left-nested API clients
116-- | Match client structure with client functions, regarding left-nested API clients
servant-client-core/src/Servant/Client/Core/Internal/Request.hs+18−18
@@ -7,7 +7,7 @@
7{-# LANGUAGE ScopedTypeVariables #-}
7{-# LANGUAGE ScopedTypeVariables #-}
8{-# LANGUAGE TypeFamilies #-}
8{-# LANGUAGE TypeFamilies #-}
9
9
10−module Servant.Common.Request where
10+module Servant.Client.Core.Internal.Request where
11
11
12import Prelude ()
12import Prelude ()
13import Prelude.Compat
13import Prelude.Compat
@@ -16,13 +16,12 @@ import qualified Data.ByteString.Builder as Builder
16import qualified Data.ByteString.Lazy as LBS
16import qualified Data.ByteString.Lazy as LBS
17import Data.Semigroup ((<>))
17import Data.Semigroup ((<>))
18import qualified Data.Sequence as Seq
18import qualified Data.Sequence as Seq
19−import Data.String.Conversions (cs)
20import Data.Text (Text)
19import Data.Text (Text)
21import Data.Typeable (Typeable)
20import Data.Typeable (Typeable)
22import GHC.Generics (Generic)
21import GHC.Generics (Generic)
23import Network.HTTP.Media (MediaType)
22import Network.HTTP.Media (MediaType)
24import Network.HTTP.Types (Header, HeaderName, HttpVersion,
23import Network.HTTP.Types (Header, HeaderName, HttpVersion,
25− Method, QueryItem, Status, http11)
24+ QueryItem, Status, http11)
26import Web.HttpApiData (ToHttpApiData, toEncodedUrlPiece,
25import Web.HttpApiData (ToHttpApiData, toEncodedUrlPiece,
27 toHeader)
26 toHeader)
28
27
@@ -126,21 +125,22 @@ setRequestBody b t req = req { requestBody = Just (b, t) }
126 {-toProperHeader (name, val) =-}
125 {-toProperHeader (name, val) =-}
127 {-(fromString name, encodeUtf8 val)-}
126 {-(fromString name, encodeUtf8 val)-}
128
127
128+
129−#if !MIN_VERSION_http_client(0,4,30)
129+ {- #if !MIN_VERSION_http_client(0,4,30)-}
130−-- 'parseRequest' is introduced in http-client-0.4.30
130+ {--- 'parseRequest' is introduced in http-client-0.4.30-}
131−-- it differs from 'parseUrl', by not throwing exceptions on non-2xx http statuses
131+ {--- it differs from 'parseUrl', by not throwing exceptions on non-2xx http statuses-}
132−--
132+ {----}
133−-- See for implementations:
133+ {--- See for implementations:-}
134−-- http://hackage.haskell.org/package/http-client-0.4.30/docs/src/Network-HTTP-Client-Request.html#parseRequest
134+ {--- http://hackage.haskell.org/package/http-client-0.4.30/docs/src/Network-HTTP-Client-Request.html#parseRequest-}
135−-- http://hackage.haskell.org/package/http-client-0.5.0/docs/src/Network-HTTP-Client-Request.html#parseRequest
135+ {--- http://hackage.haskell.org/package/http-client-0.5.0/docs/src/Network-HTTP-Client-Request.html#parseRequest-}
136−parseRequest :: MonadThrow m => String -> m Request
136+ {-parseRequest :: MonadThrow m => String -> m Request-}
137−parseRequest url = liftM disableStatusCheck (parseUrl url)
137+ {-parseRequest url = liftM disableStatusCheck (parseUrl url)-}
138− where
138+ {-where-}
139− disableStatusCheck req = req { checkStatus = \ _status _headers _cookies -> Nothing }
139+ {-disableStatusCheck req = req { checkStatus = \ _status _headers _cookies -> Nothing }-}
140−#endif
140+ {- #endif-}
141
141
142
142
143−-- * performing requests
143+ {--- * performing requests-}
144
144
145−displayHttpRequest :: Method -> String
145+ {-displayHttpRequest :: Method -> String-}
146−displayHttpRequest httpmethod = "HTTP " ++ cs httpmethod ++ " request"
146+ {-displayHttpRequest httpmethod = "HTTP " ++ cs httpmethod ++ " request"-}
servant-client/servant-client.cabal−13
@@ -42,23 +42,10 @@ library
42 , base-compat >= 0.9.1 && < 0.10
42 , base-compat >= 0.9.1 && < 0.10
43 , aeson >= 0.7 && < 1.3
43 , aeson >= 0.7 && < 1.3
44 , attoparsec >= 0.12 && < 0.14
44 , attoparsec >= 0.12 && < 0.14
45− , base64-bytestring >= 1.0.0.1 && < 1.1
46− , bytestring >= 0.10 && < 0.11
47− , containers >= 0.5 && < 0.6
48− , exceptions >= 0.8 && < 0.9
49− , generics-sop >= 0.1.0.0 && < 0.4
50− , http-api-data >= 0.3.6 && < 0.4
51 , http-client >= 0.4.18.1 && < 0.6
45 , http-client >= 0.4.18.1 && < 0.6
52 , http-client-tls >= 0.2.2 && < 0.4
46 , http-client-tls >= 0.2.2 && < 0.4
53− , http-media >= 0.6.2 && < 0.8
54− , http-types >= 0.8.6 && < 0.10
55 , monad-control >= 1.0.0.4 && < 1.1
47 , monad-control >= 1.0.0.4 && < 1.1
56− , network-uri >= 2.6 && < 2.7
57− , safe >= 0.3.9 && < 0.4
58 , semigroupoids >= 4.3 && < 5.3
48 , semigroupoids >= 4.3 && < 5.3
59− , servant == 0.11.*
60− , string-conversions >= 0.3 && < 0.5
61− , text >= 1.2 && < 1.3
62 , transformers >= 0.3 && < 0.6
49 , transformers >= 0.3 && < 0.6
63 , transformers-base >= 0.4.4 && < 0.5
50 , transformers-base >= 0.4.4 && < 0.5
64 , transformers-compat >= 0.4 && < 0.6
51 , transformers-compat >= 0.4 && < 0.6
stack-ghc-7.10.3.yaml+1
@@ -2,6 +2,7 @@ flags: {}
2packages:
2packages:
3- servant/
3- servant/
4- servant-client/
4- servant-client/
5+- servant-client-core/
5- servant-docs/
6- servant-docs/
6- servant-foreign/
7- servant-foreign/
7- servant-server/
8- servant-server/
stack-ghc-7.8.4.yaml+1
@@ -2,6 +2,7 @@ flags: {}
2packages:
2packages:
3- servant/
3- servant/
4- servant-client/
4- servant-client/
5+- servant-client-core/
5- servant-docs/
6- servant-docs/
6- servant-foreign/
7- servant-foreign/
7- servant-server/
8- servant-server/
stack-ghc-8.2.1.yaml+1
@@ -1,6 +1,7 @@
1resolver: nightly-2017-09-01
1resolver: nightly-2017-09-01
2packages:
2packages:
3- servant-client/
3- servant-client/
4+- servant-client-core/
4- servant-docs/
5- servant-docs/
5- servant-foreign/
6- servant-foreign/
6- servant-server/
7- servant-server/
stack.yaml+1
@@ -2,6 +2,7 @@ resolver: nightly-2017-04-01
2packages:
2packages:
3- servant/
3- servant/
4- servant-client/
4- servant-client/
5+- servant-client-core/
5- servant-docs/
6- servant-docs/
6- servant-foreign/
7- servant-foreign/
7- servant-server/
8- servant-server/