More reorganization

This commit is contained in:
Julian K. Arni 2017-09-07 10:05:12 -07:00
parent 95fac329a6
commit 35599d8b38
13 changed files with 53 additions and 49 deletions

View file

@ -9,6 +9,7 @@ author: Servant Contributors
maintainer: haskell-servant-maintainers@googlegroups.com maintainer: haskell-servant-maintainers@googlegroups.com
homepage: http://haskell-servant.readthedocs.org/ homepage: http://haskell-servant.readthedocs.org/
bug-reports: http://github.com/haskell-servant/servant/issues bug-reports: http://github.com/haskell-servant/servant/issues
cabal-version: >=1.10
-- copyright: -- copyright:
category: Web category: Web
build-type: Simple build-type: Simple
@ -19,15 +20,34 @@ extra-source-files:
source-repository head source-repository head
type: git type: git
location: http://github.com/haskell-servant/servant.git location: http://github.com/haskell-servant/servant.git
cabal-version: >=1.10
library library
exposed-modules: 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: build-depends:
base >= 4.7 && < 4.11 base >= 4.7 && < 4.11
, base-compat >= 0.9.1 && < 0.10 , 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 hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010
include-dirs: include
test-suite spec test-suite spec
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0

View file

@ -16,7 +16,7 @@
-- | This module provides 'client' which can automatically generate -- | This module provides 'client' which can automatically generate
-- querying functions for each endpoint just from the type representing your -- querying functions for each endpoint just from the type representing your
-- API. -- API.
module Servant.Client module Servant.Client.Core
( AuthClientData ( AuthClientData
, AuthenticateReq(..) , AuthenticateReq(..)
, client , client

View file

@ -4,13 +4,9 @@
-- | Authentication for clients -- | Authentication for clients
module Servant.Client.Experimental.Auth ( module Servant.Client.Core.Internal.Auth where
AuthenticateReq(AuthenticateReq, unAuthReq)
, AuthClientData
, mkAuthenticateReq
) where
import Servant.Common.Req (Request) import Servant.Client.Core.Internal.Request (Request)
-- | For a resource protected by authentication (e.g. AuthProtect), we need -- | For a resource protected by authentication (e.g. AuthProtect), we need
-- to provide the client with some data used to add authentication data -- to provide the client with some data used to add authentication data

View file

@ -1,7 +1,7 @@
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ViewPatterns #-} {-# LANGUAGE ViewPatterns #-}
module Servant.Common.BaseUrl ( module Servant.Client.Core.Internal.BaseUrl (
-- * types -- * types
BaseUrl (..) BaseUrl (..)
, InvalidBaseUrlException , InvalidBaseUrlException

View file

@ -4,14 +4,12 @@
-- | Basic Authentication for clients -- | Basic Authentication for clients
module Servant.Common.BasicAuth ( module Servant.Client.Core.Internal.BasicAuth where
basicAuthReq
) where
import Data.ByteString.Base64 (encode) import Data.ByteString.Base64 (encode)
import Data.Monoid ((<>)) import Data.Monoid ((<>))
import Data.Text.Encoding (decodeUtf8) 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)) import Servant.API.BasicAuth (BasicAuthData(BasicAuthData))
-- | Authenticate a request using Basic Authentication -- | Authenticate a request using Basic Authentication

View file

@ -1,10 +1,10 @@
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-| Types for possible backends to run client-side `Request` queries -} {-| 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 Data.Proxy
import Network.HTTP.Types 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 class (Monad m) => RunClient m ct where
runRequest :: Proxy ct runRequest :: Proxy ct

View file

@ -10,7 +10,7 @@
#include "overlapping-compat.h" #include "overlapping-compat.h"
module Servant.Client.Generic module Servant.Client.Core.Internal.Generic
( ClientLike(..) ( ClientLike(..)
, genericMkClientL , genericMkClientL
, genericMkClientP , genericMkClientP
@ -18,7 +18,6 @@ module Servant.Client.Generic
import Generics.SOP (Code, Generic, I(..), NP(..), NS(Z), SOP(..), to) import Generics.SOP (Code, Generic, I(..), NP(..), NS(Z), SOP(..), to)
import Servant.API ((:<|>)(..)) import Servant.API ((:<|>)(..))
import Servant.Client (ClientM)
-- | This class allows us to match client structure with client functions -- | This class allows us to match client structure with client functions
-- produced with 'client' without explicit pattern-matching. -- produced with 'client' without explicit pattern-matching.
@ -111,7 +110,7 @@ instance ClientLike client custom
=> ClientLike (a -> client) (a -> custom) where => ClientLike (a -> client) (a -> custom) where
mkClient c = mkClient . c mkClient c = mkClient . c
instance ClientLike (ClientM a) (ClientM a) where instance ClientLike (m a) (m a) where
mkClient = id mkClient = id
-- | Match client structure with client functions, regarding left-nested API clients -- | Match client structure with client functions, regarding left-nested API clients

View file

@ -7,7 +7,7 @@
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
module Servant.Common.Request where module Servant.Client.Core.Internal.Request where
import Prelude () import Prelude ()
import Prelude.Compat import Prelude.Compat
@ -16,13 +16,12 @@ import qualified Data.ByteString.Builder as Builder
import qualified Data.ByteString.Lazy as LBS import qualified Data.ByteString.Lazy as LBS
import Data.Semigroup ((<>)) import Data.Semigroup ((<>))
import qualified Data.Sequence as Seq import qualified Data.Sequence as Seq
import Data.String.Conversions (cs)
import Data.Text (Text) import Data.Text (Text)
import Data.Typeable (Typeable) import Data.Typeable (Typeable)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Network.HTTP.Media (MediaType) import Network.HTTP.Media (MediaType)
import Network.HTTP.Types (Header, HeaderName, HttpVersion, import Network.HTTP.Types (Header, HeaderName, HttpVersion,
Method, QueryItem, Status, http11) QueryItem, Status, http11)
import Web.HttpApiData (ToHttpApiData, toEncodedUrlPiece, import Web.HttpApiData (ToHttpApiData, toEncodedUrlPiece,
toHeader) toHeader)
@ -126,21 +125,22 @@ setRequestBody b t req = req { requestBody = Just (b, t) }
{-toProperHeader (name, val) =-} {-toProperHeader (name, val) =-}
{-(fromString name, encodeUtf8 val)-} {-(fromString name, encodeUtf8 val)-}
#if !MIN_VERSION_http_client(0,4,30)
-- 'parseRequest' is introduced in http-client-0.4.30 {- #if !MIN_VERSION_http_client(0,4,30)-}
-- it differs from 'parseUrl', by not throwing exceptions on non-2xx http statuses {--- '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 {--- See for implementations:-}
-- http://hackage.haskell.org/package/http-client-0.5.0/docs/src/Network-HTTP-Client-Request.html#parseRequest {--- http://hackage.haskell.org/package/http-client-0.4.30/docs/src/Network-HTTP-Client-Request.html#parseRequest-}
parseRequest :: MonadThrow m => String -> m Request {--- http://hackage.haskell.org/package/http-client-0.5.0/docs/src/Network-HTTP-Client-Request.html#parseRequest-}
parseRequest url = liftM disableStatusCheck (parseUrl url) {-parseRequest :: MonadThrow m => String -> m Request-}
where {-parseRequest url = liftM disableStatusCheck (parseUrl url)-}
disableStatusCheck req = req { checkStatus = \ _status _headers _cookies -> Nothing } {-where-}
#endif {-disableStatusCheck req = req { checkStatus = \ _status _headers _cookies -> Nothing }-}
{- #endif-}
-- * performing requests {--- * performing requests-}
displayHttpRequest :: Method -> String {-displayHttpRequest :: Method -> String-}
displayHttpRequest httpmethod = "HTTP " ++ cs httpmethod ++ " request" {-displayHttpRequest httpmethod = "HTTP " ++ cs httpmethod ++ " request"-}

View file

@ -42,23 +42,10 @@ library
, base-compat >= 0.9.1 && < 0.10 , base-compat >= 0.9.1 && < 0.10
, aeson >= 0.7 && < 1.3 , aeson >= 0.7 && < 1.3
, attoparsec >= 0.12 && < 0.14 , 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 >= 0.4.18.1 && < 0.6
, http-client-tls >= 0.2.2 && < 0.4 , 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 , 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 , 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 >= 0.3 && < 0.6
, transformers-base >= 0.4.4 && < 0.5 , transformers-base >= 0.4.4 && < 0.5
, transformers-compat >= 0.4 && < 0.6 , transformers-compat >= 0.4 && < 0.6

View file

@ -2,6 +2,7 @@ flags: {}
packages: packages:
- servant/ - servant/
- servant-client/ - servant-client/
- servant-client-core/
- servant-docs/ - servant-docs/
- servant-foreign/ - servant-foreign/
- servant-server/ - servant-server/

View file

@ -2,6 +2,7 @@ flags: {}
packages: packages:
- servant/ - servant/
- servant-client/ - servant-client/
- servant-client-core/
- servant-docs/ - servant-docs/
- servant-foreign/ - servant-foreign/
- servant-server/ - servant-server/

View file

@ -1,6 +1,7 @@
resolver: nightly-2017-09-01 resolver: nightly-2017-09-01
packages: packages:
- servant-client/ - servant-client/
- servant-client-core/
- servant-docs/ - servant-docs/
- servant-foreign/ - servant-foreign/
- servant-server/ - servant-server/

View file

@ -2,6 +2,7 @@ resolver: nightly-2017-04-01
packages: packages:
- servant/ - servant/
- servant-client/ - servant-client/
- servant-client-core/
- servant-docs/ - servant-docs/
- servant-foreign/ - servant-foreign/
- servant-server/ - servant-server/