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
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

View File

@ -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

View File

@ -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

View File

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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"-}

View File

@ -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

View File

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

View File

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

View File

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

View File

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