Apply stylish-haskell on all modules
This commit is contained in:
parent
e3c91ec579
commit
f9bcc15d0b
42 changed files with 567 additions and 431 deletions
|
@ -17,28 +17,43 @@ import Prelude.Compat
|
|||
import Control.Concurrent.STM.TVar
|
||||
import Control.Exception
|
||||
import Control.Monad
|
||||
import Control.Monad.Base (MonadBase (..))
|
||||
import Control.Monad.Catch (MonadCatch, MonadThrow)
|
||||
import Control.Monad.Error.Class (MonadError (..))
|
||||
import Control.Monad.Base
|
||||
(MonadBase (..))
|
||||
import Control.Monad.Catch
|
||||
(MonadCatch, MonadThrow)
|
||||
import Control.Monad.Error.Class
|
||||
(MonadError (..))
|
||||
import Control.Monad.Reader
|
||||
import Control.Monad.STM (atomically)
|
||||
import Control.Monad.Trans.Control (MonadBaseControl (..))
|
||||
import Control.Monad.STM
|
||||
(atomically)
|
||||
import Control.Monad.Trans.Control
|
||||
(MonadBaseControl (..))
|
||||
import Control.Monad.Trans.Except
|
||||
import Data.ByteString.Builder (toLazyByteString)
|
||||
import Data.ByteString.Builder
|
||||
(toLazyByteString)
|
||||
import qualified Data.ByteString.Lazy as BSL
|
||||
import Data.Foldable (toList, for_)
|
||||
import Data.Functor.Alt (Alt (..))
|
||||
import Data.Maybe (maybeToList)
|
||||
import Data.Semigroup ((<>))
|
||||
import Data.Proxy (Proxy (..))
|
||||
import Data.Sequence (fromList)
|
||||
import Data.String (fromString)
|
||||
import Data.Foldable
|
||||
(for_, toList)
|
||||
import Data.Functor.Alt
|
||||
(Alt (..))
|
||||
import Data.Maybe
|
||||
(maybeToList)
|
||||
import Data.Proxy
|
||||
(Proxy (..))
|
||||
import Data.Semigroup
|
||||
((<>))
|
||||
import Data.Sequence
|
||||
(fromList)
|
||||
import Data.String
|
||||
(fromString)
|
||||
import qualified Data.Text as T
|
||||
import Data.Time.Clock (getCurrentTime)
|
||||
import Data.Time.Clock
|
||||
(getCurrentTime)
|
||||
import GHC.Generics
|
||||
import Network.HTTP.Media (renderHeader)
|
||||
import Network.HTTP.Types (hContentType, renderQuery,
|
||||
statusCode)
|
||||
import Network.HTTP.Media
|
||||
(renderHeader)
|
||||
import Network.HTTP.Types
|
||||
(hContentType, renderQuery, statusCode)
|
||||
import Servant.Client.Core
|
||||
|
||||
import qualified Network.HTTP.Client as Client
|
||||
|
|
|
@ -29,53 +29,50 @@ module Servant.ClientSpec (spec, Person(..), startWaiApp, endWaiApp) where
|
|||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
|
||||
import Control.Arrow (left)
|
||||
import Control.Concurrent (ThreadId, forkIO,
|
||||
killThread)
|
||||
import Control.Exception (bracket)
|
||||
import Control.Monad.Error.Class (throwError)
|
||||
import Control.Arrow
|
||||
(left)
|
||||
import Control.Concurrent
|
||||
(ThreadId, forkIO, killThread)
|
||||
import Control.Exception
|
||||
(bracket)
|
||||
import Control.Monad.Error.Class
|
||||
(throwError)
|
||||
import Data.Aeson
|
||||
import Data.Char (chr, isPrint)
|
||||
import Data.Foldable (forM_)
|
||||
import Data.Semigroup ((<>))
|
||||
import Data.Char
|
||||
(chr, isPrint)
|
||||
import Data.Foldable
|
||||
(forM_)
|
||||
import Data.Monoid ()
|
||||
import Data.Proxy
|
||||
import Data.Semigroup
|
||||
((<>))
|
||||
import qualified Generics.SOP as SOP
|
||||
import GHC.Generics (Generic)
|
||||
import GHC.Generics
|
||||
(Generic)
|
||||
import qualified Network.HTTP.Client as C
|
||||
import qualified Network.HTTP.Types as HTTP
|
||||
import Network.Socket
|
||||
import qualified Network.Wai as Wai
|
||||
import Network.Wai.Handler.Warp
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
import System.IO.Unsafe
|
||||
(unsafePerformIO)
|
||||
import Test.Hspec
|
||||
import Test.Hspec.QuickCheck
|
||||
import Test.HUnit
|
||||
import Test.QuickCheck
|
||||
import Web.FormUrlEncoded (FromForm, ToForm)
|
||||
import Web.FormUrlEncoded
|
||||
(FromForm, ToForm)
|
||||
|
||||
import Servant.API ((:<|>) ((:<|>)),
|
||||
(:>), AuthProtect,
|
||||
BasicAuth,
|
||||
BasicAuthData (..),
|
||||
Capture,
|
||||
CaptureAll, Delete,
|
||||
DeleteNoContent,
|
||||
EmptyAPI, addHeader,
|
||||
FormUrlEncoded,
|
||||
Get, Header,
|
||||
Headers, JSON,
|
||||
NoContent (NoContent),
|
||||
Post, Put, Raw,
|
||||
QueryFlag,
|
||||
QueryParam,
|
||||
QueryParams,
|
||||
ReqBody,
|
||||
getHeaders)
|
||||
import Servant.API
|
||||
((:<|>) ((:<|>)), (:>), AuthProtect, BasicAuth,
|
||||
BasicAuthData (..), Capture, CaptureAll, Delete,
|
||||
DeleteNoContent, EmptyAPI, FormUrlEncoded, Get, Header,
|
||||
Headers, JSON, NoContent (NoContent), Post, Put, QueryFlag,
|
||||
QueryParam, QueryParams, Raw, ReqBody, addHeader, getHeaders)
|
||||
import Servant.API.Internal.Test.ComprehensiveAPI
|
||||
import Servant.Client
|
||||
import qualified Servant.Client.Core.Internal.Request as Req
|
||||
import qualified Servant.Client.Core.Internal.Auth as Auth
|
||||
import qualified Servant.Client.Core.Internal.Request as Req
|
||||
import Servant.Server
|
||||
import Servant.Server.Experimental.Auth
|
||||
|
||||
|
|
|
@ -26,31 +26,36 @@
|
|||
#include "overlapping-compat.h"
|
||||
module Servant.StreamSpec (spec) where
|
||||
|
||||
import Control.Monad (replicateM_, void)
|
||||
import Control.Monad
|
||||
(replicateM_, void)
|
||||
import qualified Data.ByteString as BS
|
||||
import Data.Proxy
|
||||
import qualified Network.HTTP.Client as C
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
import System.IO (IOMode (ReadMode), withFile)
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
import System.IO
|
||||
(IOMode (ReadMode), withFile)
|
||||
import System.IO.Unsafe
|
||||
(unsafePerformIO)
|
||||
import Test.Hspec
|
||||
import Test.QuickCheck
|
||||
|
||||
import Servant.API ((:<|>) ((:<|>)), (:>), JSON,
|
||||
NetstringFraming, NewlineFraming,
|
||||
OctetStream, ResultStream (..),
|
||||
StreamGenerator (..), StreamGet,
|
||||
NoFraming)
|
||||
import Servant.API
|
||||
((:<|>) ((:<|>)), (:>), JSON, NetstringFraming,
|
||||
NewlineFraming, NoFraming, OctetStream, ResultStream (..),
|
||||
StreamGenerator (..), StreamGet)
|
||||
import Servant.Client
|
||||
import Servant.ClientSpec (Person (..))
|
||||
import Servant.ClientSpec
|
||||
(Person (..))
|
||||
import qualified Servant.ClientSpec as CS
|
||||
import Servant.Server
|
||||
|
||||
#if MIN_VERSION_base(4,10,0)
|
||||
import GHC.Stats (gcdetails_mem_in_use_bytes, gc, getRTSStats)
|
||||
import GHC.Stats
|
||||
(gc, gcdetails_mem_in_use_bytes, getRTSStats)
|
||||
#else
|
||||
import GHC.Stats (currentBytesUsed, getGCStats)
|
||||
import GHC.Stats
|
||||
(currentBytesUsed, getGCStats)
|
||||
#endif
|
||||
|
||||
spec :: Spec
|
||||
|
|
|
@ -9,7 +9,8 @@ import Control.Lens
|
|||
import Data.Aeson
|
||||
import Data.Proxy
|
||||
import Data.String.Conversions
|
||||
import Data.Text (Text)
|
||||
import Data.Text
|
||||
(Text)
|
||||
import GHC.Generics
|
||||
import Servant.API
|
||||
import Servant.Docs
|
||||
|
|
|
@ -24,29 +24,41 @@ import Prelude ()
|
|||
import Prelude.Compat
|
||||
|
||||
import Control.Applicative
|
||||
import Control.Arrow (second)
|
||||
import Control.Lens (makeLenses, mapped, over,
|
||||
traversed, view, (%~), (&), (.~),
|
||||
import Control.Arrow
|
||||
(second)
|
||||
import Control.Lens
|
||||
(makeLenses, mapped, over, traversed, view, (%~), (&), (.~),
|
||||
(<>~), (^.), (|>))
|
||||
import qualified Control.Monad.Omega as Omega
|
||||
import qualified Data.ByteString.Char8 as BSC
|
||||
import Data.ByteString.Lazy.Char8 (ByteString)
|
||||
import Data.ByteString.Lazy.Char8
|
||||
(ByteString)
|
||||
import qualified Data.CaseInsensitive as CI
|
||||
import Data.Foldable (fold)
|
||||
import Data.Hashable (Hashable)
|
||||
import Data.HashMap.Strict (HashMap)
|
||||
import Data.List.Compat (intercalate, intersperse, sort)
|
||||
import Data.List.NonEmpty (NonEmpty ((:|)), groupWith)
|
||||
import Data.Foldable
|
||||
(fold)
|
||||
import Data.Hashable
|
||||
(Hashable)
|
||||
import Data.HashMap.Strict
|
||||
(HashMap)
|
||||
import Data.List.Compat
|
||||
(intercalate, intersperse, sort)
|
||||
import Data.List.NonEmpty
|
||||
(NonEmpty ((:|)), groupWith)
|
||||
import qualified Data.List.NonEmpty as NE
|
||||
import Data.Maybe
|
||||
import Data.Monoid (All (..), Any (..), Dual (..),
|
||||
First (..), Last (..),
|
||||
import Data.Monoid
|
||||
(All (..), Any (..), Dual (..), First (..), Last (..),
|
||||
Product (..), Sum (..))
|
||||
import Data.Ord (comparing)
|
||||
import Data.Proxy (Proxy (Proxy))
|
||||
import Data.Semigroup (Semigroup (..))
|
||||
import Data.String.Conversions (cs)
|
||||
import Data.Text (Text, unpack)
|
||||
import Data.Ord
|
||||
(comparing)
|
||||
import Data.Proxy
|
||||
(Proxy (Proxy))
|
||||
import Data.Semigroup
|
||||
(Semigroup (..))
|
||||
import Data.String.Conversions
|
||||
(cs)
|
||||
import Data.Text
|
||||
(Text, unpack)
|
||||
import GHC.Generics
|
||||
import GHC.TypeLits
|
||||
import Servant.API
|
||||
|
|
|
@ -4,15 +4,19 @@
|
|||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
|
||||
module Servant.Docs.Internal.Pretty where
|
||||
|
||||
import Data.Aeson (ToJSON(..))
|
||||
import Data.Aeson.Encode.Pretty (encodePretty)
|
||||
import Data.Proxy (Proxy(Proxy))
|
||||
import Network.HTTP.Media ((//))
|
||||
import Data.Aeson
|
||||
(ToJSON (..))
|
||||
import Data.Aeson.Encode.Pretty
|
||||
(encodePretty)
|
||||
import Data.Proxy
|
||||
(Proxy (Proxy))
|
||||
import Network.HTTP.Media
|
||||
((//))
|
||||
import Servant.API
|
||||
|
||||
-- | PrettyJSON content type.
|
||||
|
|
|
@ -20,7 +20,8 @@ import Control.Lens
|
|||
import Data.Aeson
|
||||
import Data.Monoid
|
||||
import Data.Proxy
|
||||
import Data.String.Conversions (cs)
|
||||
import Data.String.Conversions
|
||||
(cs)
|
||||
import GHC.Generics
|
||||
import Test.Hspec
|
||||
|
||||
|
|
|
@ -52,5 +52,5 @@ module Servant.Foreign
|
|||
) where
|
||||
|
||||
import Servant.API
|
||||
import Servant.Foreign.Internal
|
||||
import Servant.Foreign.Inflections
|
||||
import Servant.Foreign.Internal
|
||||
|
|
|
@ -10,11 +10,14 @@ module Servant.Foreign.Inflections
|
|||
) where
|
||||
|
||||
|
||||
import Control.Lens hiding (cons)
|
||||
import Control.Lens hiding
|
||||
(cons)
|
||||
import qualified Data.Char as C
|
||||
import Data.Monoid
|
||||
import Data.Text hiding (map)
|
||||
import Prelude hiding (head, tail)
|
||||
import Data.Text hiding
|
||||
(map)
|
||||
import Prelude hiding
|
||||
(head, tail)
|
||||
import Servant.Foreign.Internal
|
||||
|
||||
concatCaseL :: Getter FunctionName Text
|
||||
|
|
|
@ -23,20 +23,25 @@ module Servant.Foreign.Internal where
|
|||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
|
||||
import Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~),
|
||||
(.~))
|
||||
import Data.Data (Data)
|
||||
import Control.Lens
|
||||
(Getter, makeLenses, makePrisms, (%~), (&), (.~), (<>~))
|
||||
import Data.Data
|
||||
(Data)
|
||||
import Data.Proxy
|
||||
import Data.Semigroup (Semigroup)
|
||||
import Data.Semigroup
|
||||
(Semigroup)
|
||||
import Data.String
|
||||
import Data.Text
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Text.Encoding (decodeUtf8)
|
||||
import Data.Text.Encoding
|
||||
(decodeUtf8)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import GHC.TypeLits
|
||||
import qualified Network.HTTP.Types as HTTP
|
||||
import Servant.API
|
||||
import Servant.API.Modifiers
|
||||
(RequiredArgument)
|
||||
import Servant.API.TypeLevel
|
||||
import Servant.API.Modifiers (RequiredArgument)
|
||||
|
||||
newtype FunctionName = FunctionName { unFunctionName :: [Text] }
|
||||
deriving (Data, Show, Eq, Semigroup, Monoid, Typeable)
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
|
||||
module Servant.ForeignSpec where
|
||||
|
||||
import Data.Monoid ((<>))
|
||||
import Data.Monoid
|
||||
((<>))
|
||||
import Data.Proxy
|
||||
import Servant.Foreign
|
||||
import Servant.API.Internal.Test.ComprehensiveAPI
|
||||
import Servant.Foreign
|
||||
|
||||
import Test.Hspec
|
||||
|
||||
|
|
|
@ -13,9 +13,10 @@ module Servant (
|
|||
throwError
|
||||
) where
|
||||
|
||||
import Control.Monad.Error.Class (throwError)
|
||||
import Control.Monad.Error.Class
|
||||
(throwError)
|
||||
import Data.Proxy
|
||||
import Servant.API
|
||||
import Servant.Server
|
||||
import Servant.Links
|
||||
import Servant.Server
|
||||
import Servant.Utils.StaticFiles
|
||||
|
|
|
@ -92,10 +92,14 @@ module Servant.Server
|
|||
|
||||
) where
|
||||
|
||||
import Data.Proxy (Proxy (..))
|
||||
import Data.Tagged (Tagged (..))
|
||||
import Data.Text (Text)
|
||||
import Network.Wai (Application)
|
||||
import Data.Proxy
|
||||
(Proxy (..))
|
||||
import Data.Tagged
|
||||
(Tagged (..))
|
||||
import Data.Text
|
||||
(Text)
|
||||
import Network.Wai
|
||||
(Application)
|
||||
import Servant.Server.Internal
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
|
@ -12,22 +12,26 @@
|
|||
|
||||
module Servant.Server.Experimental.Auth where
|
||||
|
||||
import Control.Monad.Trans (liftIO)
|
||||
import Data.Proxy (Proxy (Proxy))
|
||||
import Data.Typeable (Typeable)
|
||||
import GHC.Generics (Generic)
|
||||
import Network.Wai (Request)
|
||||
import Control.Monad.Trans
|
||||
(liftIO)
|
||||
import Data.Proxy
|
||||
(Proxy (Proxy))
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import GHC.Generics
|
||||
(Generic)
|
||||
import Network.Wai
|
||||
(Request)
|
||||
|
||||
import Servant ((:>))
|
||||
import Servant
|
||||
((:>))
|
||||
import Servant.API.Experimental.Auth
|
||||
import Servant.Server.Internal (HasContextEntry,
|
||||
HasServer (..),
|
||||
getContextEntry)
|
||||
import Servant.Server.Internal.RoutingApplication (addAuthCheck,
|
||||
delayedFailFatal,
|
||||
DelayedIO,
|
||||
withRequest)
|
||||
import Servant.Server.Internal.Handler (Handler, runHandler)
|
||||
import Servant.Server.Internal
|
||||
(HasContextEntry, HasServer (..), getContextEntry)
|
||||
import Servant.Server.Internal.Handler
|
||||
(Handler, runHandler)
|
||||
import Servant.Server.Internal.RoutingApplication
|
||||
(DelayedIO, addAuthCheck, delayedFailFatal, withRequest)
|
||||
|
||||
-- * General Auth
|
||||
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
#define HAS_TYPE_ERROR
|
||||
#endif
|
||||
|
||||
#ifdef HAS_TYPE_ERROR
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
#endif
|
||||
|
||||
#include "overlapping-compat.h"
|
||||
|
||||
module Servant.Server.Internal
|
||||
|
@ -34,72 +30,74 @@ module Servant.Server.Internal
|
|||
, module Servant.Server.Internal.ServantErr
|
||||
) where
|
||||
|
||||
import Control.Monad (join, when)
|
||||
import Control.Monad.Trans (liftIO)
|
||||
import Control.Monad.Trans.Resource (runResourceT)
|
||||
import Control.Monad
|
||||
(join, when)
|
||||
import Control.Monad.Trans
|
||||
(liftIO)
|
||||
import Control.Monad.Trans.Resource
|
||||
(runResourceT)
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Builder as BB
|
||||
import qualified Data.ByteString.Char8 as BC8
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import Data.Maybe (fromMaybe, mapMaybe,
|
||||
isNothing, maybeToList)
|
||||
import Data.Either (partitionEithers)
|
||||
import Data.Semigroup ((<>))
|
||||
import Data.String (IsString (..))
|
||||
import Data.String.Conversions (cs)
|
||||
import Data.Tagged (Tagged(..), retag, untag)
|
||||
import Data.Either
|
||||
(partitionEithers)
|
||||
import Data.Maybe
|
||||
(fromMaybe, isNothing, mapMaybe, maybeToList)
|
||||
import Data.Semigroup
|
||||
((<>))
|
||||
import Data.String
|
||||
(IsString (..))
|
||||
import Data.String.Conversions
|
||||
(cs)
|
||||
import Data.Tagged
|
||||
(Tagged (..), retag, untag)
|
||||
import qualified Data.Text as T
|
||||
import Data.Typeable
|
||||
import GHC.TypeLits (KnownNat, KnownSymbol, natVal,
|
||||
symbolVal)
|
||||
import Network.HTTP.Types hiding (Header, ResponseHeaders)
|
||||
import GHC.TypeLits
|
||||
(KnownNat, KnownSymbol, natVal, symbolVal)
|
||||
import qualified Network.HTTP.Media as NHM
|
||||
import Network.Socket (SockAddr)
|
||||
import Network.Wai (Application, Request,
|
||||
httpVersion, isSecure,
|
||||
lazyRequestBody,
|
||||
rawQueryString, remoteHost,
|
||||
requestHeaders, requestMethod,
|
||||
responseLBS, responseStream,
|
||||
vault)
|
||||
import Network.HTTP.Types hiding
|
||||
(Header, ResponseHeaders)
|
||||
import Network.Socket
|
||||
(SockAddr)
|
||||
import Network.Wai
|
||||
(Application, Request, httpVersion, isSecure, lazyRequestBody,
|
||||
rawQueryString, remoteHost, requestHeaders, requestMethod,
|
||||
responseLBS, responseStream, vault)
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
import Web.HttpApiData (FromHttpApiData, parseHeader,
|
||||
parseQueryParam,
|
||||
parseUrlPieceMaybe,
|
||||
parseUrlPieces)
|
||||
import Servant.API ((:<|>) (..), (:>), BasicAuth, Capture',
|
||||
CaptureAll, Verb, EmptyAPI,
|
||||
ReflectMethod(reflectMethod),
|
||||
IsSecure(..), Header', QueryFlag,
|
||||
QueryParam', QueryParams, Raw,
|
||||
RemoteHost, ReqBody', Vault,
|
||||
WithNamedContext,
|
||||
Description, Summary,
|
||||
Accept(..),
|
||||
FramingRender(..), Stream,
|
||||
StreamGenerator(..), ToStreamGenerator(..),
|
||||
BoundaryStrategy(..),
|
||||
If, SBool (..), SBoolI (..))
|
||||
import Servant.API.Modifiers (unfoldRequestArgument, RequestArgument, FoldRequired, FoldLenient)
|
||||
import Servant.API.ContentTypes (AcceptHeader (..),
|
||||
AllCTRender (..),
|
||||
AllCTUnrender (..),
|
||||
AllMime,
|
||||
MimeRender(..),
|
||||
canHandleAcceptH)
|
||||
import Servant.API.ResponseHeaders (GetHeaders, Headers, getHeaders,
|
||||
getResponse)
|
||||
import Servant.API
|
||||
((:<|>) (..), (:>), Accept (..), BasicAuth,
|
||||
BoundaryStrategy (..), Capture', CaptureAll, Description,
|
||||
EmptyAPI, FramingRender (..), Header', If, IsSecure (..),
|
||||
QueryFlag, QueryParam', QueryParams, Raw,
|
||||
ReflectMethod (reflectMethod), RemoteHost, ReqBody',
|
||||
SBool (..), SBoolI (..), Stream, StreamGenerator (..),
|
||||
Summary, ToStreamGenerator (..), Vault, Verb,
|
||||
WithNamedContext)
|
||||
import Servant.API.ContentTypes
|
||||
(AcceptHeader (..), AllCTRender (..), AllCTUnrender (..),
|
||||
AllMime, MimeRender (..), canHandleAcceptH)
|
||||
import Servant.API.Modifiers
|
||||
(FoldLenient, FoldRequired, RequestArgument,
|
||||
unfoldRequestArgument)
|
||||
import Servant.API.ResponseHeaders
|
||||
(GetHeaders, Headers, getHeaders, getResponse)
|
||||
import Web.HttpApiData
|
||||
(FromHttpApiData, parseHeader, parseQueryParam,
|
||||
parseUrlPieceMaybe, parseUrlPieces)
|
||||
|
||||
import Servant.Server.Internal.Context
|
||||
import Servant.Server.Internal.BasicAuth
|
||||
import Servant.Server.Internal.Context
|
||||
import Servant.Server.Internal.Handler
|
||||
import Servant.Server.Internal.Router
|
||||
import Servant.Server.Internal.RoutingApplication
|
||||
import Servant.Server.Internal.ServantErr
|
||||
|
||||
#ifdef HAS_TYPE_ERROR
|
||||
import GHC.TypeLits (TypeError, ErrorMessage (..))
|
||||
import GHC.TypeLits
|
||||
(ErrorMessage (..), TypeError)
|
||||
#endif
|
||||
|
||||
class HasServer api context where
|
||||
|
|
|
@ -5,18 +5,27 @@
|
|||
|
||||
module Servant.Server.Internal.BasicAuth where
|
||||
|
||||
import Control.Monad (guard)
|
||||
import Control.Monad.Trans (liftIO)
|
||||
import Control.Monad
|
||||
(guard)
|
||||
import Control.Monad.Trans
|
||||
(liftIO)
|
||||
import qualified Data.ByteString as BS
|
||||
import Data.ByteString.Base64 (decodeLenient)
|
||||
import Data.Monoid ((<>))
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Word8 (isSpace, toLower, _colon)
|
||||
import Data.ByteString.Base64
|
||||
(decodeLenient)
|
||||
import Data.Monoid
|
||||
((<>))
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import Data.Word8
|
||||
(isSpace, toLower, _colon)
|
||||
import GHC.Generics
|
||||
import Network.HTTP.Types (Header)
|
||||
import Network.Wai (Request, requestHeaders)
|
||||
import Network.HTTP.Types
|
||||
(Header)
|
||||
import Network.Wai
|
||||
(Request, requestHeaders)
|
||||
|
||||
import Servant.API.BasicAuth (BasicAuthData(BasicAuthData))
|
||||
import Servant.API.BasicAuth
|
||||
(BasicAuthData (BasicAuthData))
|
||||
import Servant.Server.Internal.RoutingApplication
|
||||
import Servant.Server.Internal.ServantErr
|
||||
|
||||
|
|
|
@ -8,14 +8,22 @@ module Servant.Server.Internal.Handler where
|
|||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
|
||||
import Control.Monad.Base (MonadBase (..))
|
||||
import Control.Monad.Catch (MonadCatch, MonadThrow)
|
||||
import Control.Monad.Error.Class (MonadError)
|
||||
import Control.Monad.IO.Class (MonadIO)
|
||||
import Control.Monad.Trans.Control (MonadBaseControl (..))
|
||||
import Control.Monad.Trans.Except (ExceptT, runExceptT)
|
||||
import GHC.Generics (Generic)
|
||||
import Servant.Server.Internal.ServantErr (ServantErr)
|
||||
import Control.Monad.Base
|
||||
(MonadBase (..))
|
||||
import Control.Monad.Catch
|
||||
(MonadCatch, MonadThrow)
|
||||
import Control.Monad.Error.Class
|
||||
(MonadError)
|
||||
import Control.Monad.IO.Class
|
||||
(MonadIO)
|
||||
import Control.Monad.Trans.Control
|
||||
(MonadBaseControl (..))
|
||||
import Control.Monad.Trans.Except
|
||||
(ExceptT, runExceptT)
|
||||
import GHC.Generics
|
||||
(Generic)
|
||||
import Servant.Server.Internal.ServantErr
|
||||
(ServantErr)
|
||||
|
||||
newtype Handler a = Handler { runHandler' :: ExceptT ServantErr IO a }
|
||||
deriving
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
{-# LANGUAGE DeriveFunctor #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE DeriveFunctor #-}
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Servant.Server.Internal.Router where
|
||||
|
||||
import Data.Map (Map)
|
||||
import Data.Map
|
||||
(Map)
|
||||
import qualified Data.Map as M
|
||||
import Data.Monoid
|
||||
import Data.Text (Text)
|
||||
import Data.Text
|
||||
(Text)
|
||||
import qualified Data.Text as T
|
||||
import Network.Wai (Response, pathInfo)
|
||||
import Network.Wai
|
||||
(Response, pathInfo)
|
||||
import Servant.Server.Internal.RoutingApplication
|
||||
import Servant.Server.Internal.ServantErr
|
||||
|
||||
|
|
|
@ -10,15 +10,24 @@
|
|||
{-# LANGUAGE UndecidableInstances #-}
|
||||
module Servant.Server.Internal.RoutingApplication where
|
||||
|
||||
import Control.Monad (ap, liftM)
|
||||
import Control.Monad.Base (MonadBase (..))
|
||||
import Control.Monad.Catch (MonadThrow (..))
|
||||
import Control.Monad.Reader (MonadReader (..), ReaderT (..), runReaderT)
|
||||
import Control.Monad.Trans (MonadIO (..), MonadTrans (..))
|
||||
import Control.Monad.Trans.Control (ComposeSt, MonadBaseControl (..), MonadTransControl (..),
|
||||
import Control.Monad
|
||||
(ap, liftM)
|
||||
import Control.Monad.Base
|
||||
(MonadBase (..))
|
||||
import Control.Monad.Catch
|
||||
(MonadThrow (..))
|
||||
import Control.Monad.Reader
|
||||
(MonadReader (..), ReaderT (..), runReaderT)
|
||||
import Control.Monad.Trans
|
||||
(MonadIO (..), MonadTrans (..))
|
||||
import Control.Monad.Trans.Control
|
||||
(ComposeSt, MonadBaseControl (..), MonadTransControl (..),
|
||||
defaultLiftBaseWith, defaultRestoreM)
|
||||
import Control.Monad.Trans.Resource (MonadResource (..), ResourceT, runResourceT, transResourceT, withInternalState, runInternalState)
|
||||
import Network.Wai (Application, Request, Response, ResponseReceived)
|
||||
import Control.Monad.Trans.Resource
|
||||
(MonadResource (..), ResourceT, runInternalState,
|
||||
runResourceT, transResourceT, withInternalState)
|
||||
import Network.Wai
|
||||
(Application, Request, Response, ResponseReceived)
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
import Servant.Server.Internal.Handler
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
module Servant.Server.Internal.ServantErr where
|
||||
|
||||
import Control.Exception (Exception)
|
||||
import Control.Exception
|
||||
(Exception)
|
||||
import qualified Data.ByteString.Char8 as BS
|
||||
import qualified Data.ByteString.Lazy as LBS
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import qualified Network.HTTP.Types as HTTP
|
||||
import Network.Wai (Response, responseLBS)
|
||||
import Network.Wai
|
||||
(Response, responseLBS)
|
||||
|
||||
data ServantErr = ServantErr { errHTTPCode :: Int
|
||||
, errReasonPhrase :: String
|
||||
|
|
|
@ -15,15 +15,21 @@ module Servant.Utils.StaticFiles
|
|||
serveDirectory
|
||||
) where
|
||||
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.ByteString
|
||||
(ByteString)
|
||||
import Network.Wai.Application.Static
|
||||
import Servant.API.Raw (Raw)
|
||||
import Servant.Server (ServerT, Tagged (..))
|
||||
import System.FilePath (addTrailingPathSeparator)
|
||||
import Servant.API.Raw
|
||||
(Raw)
|
||||
import Servant.Server
|
||||
(ServerT, Tagged (..))
|
||||
import System.FilePath
|
||||
(addTrailingPathSeparator)
|
||||
#if !MIN_VERSION_wai_app_static(3,1,0)
|
||||
import Filesystem.Path.CurrentOS (decodeString)
|
||||
import Filesystem.Path.CurrentOS
|
||||
(decodeString)
|
||||
#endif
|
||||
import WaiAppStatic.Storage.Filesystem (ETagLookup)
|
||||
import WaiAppStatic.Storage.Filesystem
|
||||
(ETagLookup)
|
||||
|
||||
-- | Serve anything under the specified directory as a 'Raw' endpoint.
|
||||
--
|
||||
|
|
|
@ -9,9 +9,10 @@ import Data.Proxy
|
|||
import Servant.API
|
||||
import Servant.Server
|
||||
|
||||
import Test.Hspec (Spec, describe, it)
|
||||
import Test.Hspec.Wai (get, matchStatus, post,
|
||||
shouldRespondWith, with)
|
||||
import Test.Hspec
|
||||
(Spec, describe, it)
|
||||
import Test.Hspec.Wai
|
||||
(get, matchStatus, post, shouldRespondWith, with)
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Arbitrary monad server" $ do
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
{-# LANGUAGE TypeOperators #-}
|
||||
module Servant.HoistSpec where
|
||||
|
||||
import Test.Hspec (Spec)
|
||||
import Test.Hspec
|
||||
(Spec)
|
||||
|
||||
import Servant
|
||||
|
||||
|
|
|
@ -6,16 +6,20 @@
|
|||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
module Servant.Server.ErrorSpec (spec) where
|
||||
|
||||
import Control.Monad (when)
|
||||
import Data.Aeson (encode)
|
||||
import Control.Monad
|
||||
(when)
|
||||
import Data.Aeson
|
||||
(encode)
|
||||
import qualified Data.ByteString.Char8 as BC
|
||||
import qualified Data.ByteString.Lazy.Char8 as BCL
|
||||
import Data.Monoid ((<>))
|
||||
import Data.Monoid
|
||||
((<>))
|
||||
import Data.Proxy
|
||||
import Network.HTTP.Types (hAccept, hAuthorization,
|
||||
hContentType, methodGet,
|
||||
methodPost, methodPut)
|
||||
import Safe (readMay)
|
||||
import Network.HTTP.Types
|
||||
(hAccept, hAuthorization, hContentType, methodGet, methodPost,
|
||||
methodPut)
|
||||
import Safe
|
||||
(readMay)
|
||||
import Test.Hspec
|
||||
import Test.Hspec.Wai
|
||||
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
{-# OPTIONS_GHC -fdefer-type-errors -Wwarn #-}
|
||||
module Servant.Server.Internal.ContextSpec (spec) where
|
||||
|
||||
import Data.Proxy (Proxy (..))
|
||||
import Test.Hspec (Spec, describe, it, shouldBe, context)
|
||||
import Test.ShouldNotTypecheck (shouldNotTypecheck)
|
||||
import Data.Proxy
|
||||
(Proxy (..))
|
||||
import Test.Hspec
|
||||
(Spec, context, describe, it, shouldBe)
|
||||
import Test.ShouldNotTypecheck
|
||||
(shouldNotTypecheck)
|
||||
|
||||
import Servant.API
|
||||
import Servant.Server.Internal.Context
|
||||
|
|
|
@ -11,21 +11,27 @@ module Servant.Server.Internal.RoutingApplicationSpec (spec) where
|
|||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
|
||||
import Control.Exception hiding (Handler)
|
||||
import Control.Monad.Trans.Resource (register)
|
||||
import Control.Exception hiding
|
||||
(Handler)
|
||||
import Control.Monad.IO.Class
|
||||
import Control.Monad.Trans.Resource
|
||||
(register)
|
||||
import Data.IORef
|
||||
import Data.Proxy
|
||||
import GHC.TypeLits (Symbol, KnownSymbol, symbolVal)
|
||||
import GHC.TypeLits
|
||||
(KnownSymbol, Symbol, symbolVal)
|
||||
import Network.Wai
|
||||
(defaultRequest)
|
||||
import Servant
|
||||
import Servant.Server.Internal.RoutingApplication
|
||||
import Network.Wai (defaultRequest)
|
||||
import Test.Hspec
|
||||
import Test.Hspec.Wai (request, shouldRespondWith, with)
|
||||
import Test.Hspec.Wai
|
||||
(request, shouldRespondWith, with)
|
||||
|
||||
import qualified Data.Text as T
|
||||
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
import System.IO.Unsafe
|
||||
(unsafePerformIO)
|
||||
|
||||
data TestResource x
|
||||
= TestResourceNone
|
||||
|
|
|
@ -4,17 +4,24 @@
|
|||
{-# LANGUAGE TypeOperators #-}
|
||||
module Servant.Server.RouterSpec (spec) where
|
||||
|
||||
import Control.Monad (unless)
|
||||
import Data.Proxy (Proxy(..))
|
||||
import Data.Text (unpack)
|
||||
import Network.HTTP.Types (Status (..))
|
||||
import Network.Wai (responseBuilder)
|
||||
import Network.Wai.Internal (Response (ResponseBuilder))
|
||||
import Test.Hspec
|
||||
import Test.Hspec.Wai (get, shouldRespondWith, with)
|
||||
import Control.Monad
|
||||
(unless)
|
||||
import Data.Proxy
|
||||
(Proxy (..))
|
||||
import Data.Text
|
||||
(unpack)
|
||||
import Network.HTTP.Types
|
||||
(Status (..))
|
||||
import Network.Wai
|
||||
(responseBuilder)
|
||||
import Network.Wai.Internal
|
||||
(Response (ResponseBuilder))
|
||||
import Servant.API
|
||||
import Servant.Server
|
||||
import Servant.Server.Internal
|
||||
import Test.Hspec
|
||||
import Test.Hspec.Wai
|
||||
(get, shouldRespondWith, with)
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Servant.Server.Internal.Router" $ do
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
module Servant.Server.StreamingSpec where
|
||||
|
||||
import Control.Concurrent
|
||||
import Control.Exception hiding (Handler)
|
||||
import Control.Exception hiding
|
||||
(Handler)
|
||||
import Control.Monad.IO.Class
|
||||
import qualified Data.ByteString as Strict
|
||||
import qualified Data.ByteString.Lazy as Lazy
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
module Servant.Server.UsingContextSpec where
|
||||
|
||||
import Network.Wai
|
||||
import Test.Hspec (Spec, describe, it)
|
||||
import Test.Hspec
|
||||
(Spec, describe, it)
|
||||
import Test.Hspec.Wai
|
||||
|
||||
import Servant
|
||||
|
|
|
@ -5,20 +5,29 @@
|
|||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
module Servant.Utils.StaticFilesSpec where
|
||||
|
||||
import Control.Exception (bracket)
|
||||
import Data.Proxy (Proxy (Proxy))
|
||||
import Network.Wai (Application)
|
||||
import System.Directory (createDirectory,
|
||||
getCurrentDirectory,
|
||||
setCurrentDirectory)
|
||||
import System.IO.Temp (withSystemTempDirectory)
|
||||
import Test.Hspec (Spec, around_, describe, it)
|
||||
import Test.Hspec.Wai (get, shouldRespondWith, with)
|
||||
import Control.Exception
|
||||
(bracket)
|
||||
import Data.Proxy
|
||||
(Proxy (Proxy))
|
||||
import Network.Wai
|
||||
(Application)
|
||||
import System.Directory
|
||||
(createDirectory, getCurrentDirectory, setCurrentDirectory)
|
||||
import System.IO.Temp
|
||||
(withSystemTempDirectory)
|
||||
import Test.Hspec
|
||||
(Spec, around_, describe, it)
|
||||
import Test.Hspec.Wai
|
||||
(get, shouldRespondWith, with)
|
||||
|
||||
import Servant.API ((:<|>) ((:<|>)), Capture, Get, Raw, (:>), JSON)
|
||||
import Servant.Server (Server, serve)
|
||||
import Servant.ServerSpec (Person (Person))
|
||||
import Servant.Utils.StaticFiles (serveDirectoryFileServer)
|
||||
import Servant.API
|
||||
((:<|>) ((:<|>)), (:>), Capture, Get, JSON, Raw)
|
||||
import Servant.Server
|
||||
(Server, serve)
|
||||
import Servant.ServerSpec
|
||||
(Person (Person))
|
||||
import Servant.Utils.StaticFiles
|
||||
(serveDirectoryFileServer)
|
||||
|
||||
type Api =
|
||||
"dummy_api" :> Capture "person_name" String :> Get '[JSON] Person
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
-----------------------------------------------------------------------------
|
||||
module Main where
|
||||
|
||||
import Build_doctests (flags, pkgs, module_sources)
|
||||
import Data.Foldable (traverse_)
|
||||
import Build_doctests
|
||||
(flags, module_sources, pkgs)
|
||||
import Data.Foldable
|
||||
(traverse_)
|
||||
import Test.DocTest
|
||||
|
||||
main :: IO ()
|
||||
|
|
|
@ -114,9 +114,9 @@ import Servant.API.ResponseHeaders
|
|||
ResponseHeader (..), addHeader, getHeadersHList, getResponse,
|
||||
noHeader)
|
||||
import Servant.API.Stream
|
||||
(BoundaryStrategy (..), FromResultStream (..),
|
||||
ByteStringParser (..), FramingRender (..),
|
||||
FramingUnrender (..), NetstringFraming, NewlineFraming,
|
||||
(BoundaryStrategy (..), ByteStringParser (..),
|
||||
FramingRender (..), FramingUnrender (..),
|
||||
FromResultStream (..), NetstringFraming, NewlineFraming,
|
||||
NoFraming, ResultStream (..), Stream, StreamGenerator (..),
|
||||
StreamGet, StreamPost, ToStreamGenerator (..))
|
||||
import Servant.API.Sub
|
||||
|
|
|
@ -12,25 +12,32 @@ import Prelude ()
|
|||
import Prelude.Compat
|
||||
|
||||
import Data.Aeson.Compat
|
||||
import Data.ByteString.Char8 (ByteString, append, pack)
|
||||
import Data.ByteString.Char8
|
||||
(ByteString, append, pack)
|
||||
import qualified Data.ByteString.Lazy as BSL
|
||||
import qualified Data.ByteString.Lazy.Char8 as BSL8
|
||||
import Data.Either
|
||||
import Data.Function (on)
|
||||
import Data.List (maximumBy)
|
||||
import Data.Function
|
||||
(on)
|
||||
import Data.List
|
||||
(maximumBy)
|
||||
import qualified Data.List.NonEmpty as NE
|
||||
import Data.Maybe (fromJust, isJust, isNothing)
|
||||
import Data.Maybe
|
||||
(fromJust, isJust, isNothing)
|
||||
import Data.Proxy
|
||||
import Data.String (IsString (..))
|
||||
import Data.String.Conversions (cs)
|
||||
import Data.String
|
||||
(IsString (..))
|
||||
import Data.String.Conversions
|
||||
(cs)
|
||||
import qualified Data.Text as TextS
|
||||
import qualified Data.Text.Encoding as TextSE
|
||||
import qualified Data.Text.Lazy as TextL
|
||||
import GHC.Generics
|
||||
import Test.Hspec
|
||||
import Test.QuickCheck
|
||||
import Text.Read (readMaybe)
|
||||
import "quickcheck-instances" Test.QuickCheck.Instances ()
|
||||
import Text.Read
|
||||
(readMaybe)
|
||||
|
||||
import Servant.API.ContentTypes
|
||||
|
||||
|
|
|
@ -2,21 +2,24 @@
|
|||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
#if __GLASGOW_HASKELL__ < 709
|
||||
{-# OPTIONS_GHC -fcontext-stack=41 #-}
|
||||
#endif
|
||||
module Servant.LinksSpec where
|
||||
|
||||
import Data.Proxy (Proxy (..))
|
||||
import Test.Hspec (Expectation, Spec, describe, it,
|
||||
shouldBe)
|
||||
import Data.String (fromString)
|
||||
import Data.Proxy
|
||||
(Proxy (..))
|
||||
import Data.String
|
||||
(fromString)
|
||||
import Test.Hspec
|
||||
(Expectation, Spec, describe, it, shouldBe)
|
||||
|
||||
import Servant.API
|
||||
import Servant.API.Internal.Test.ComprehensiveAPI
|
||||
(comprehensiveAPIWithoutRaw)
|
||||
import Servant.Links
|
||||
import Servant.API.Internal.Test.ComprehensiveAPI (comprehensiveAPIWithoutRaw)
|
||||
|
||||
type TestApi =
|
||||
-- Capture and query params
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
-----------------------------------------------------------------------------
|
||||
module Main where
|
||||
|
||||
import Build_doctests (flags, pkgs, module_sources)
|
||||
import Data.Foldable (traverse_)
|
||||
import Build_doctests
|
||||
(flags, module_sources, pkgs)
|
||||
import Data.Foldable
|
||||
(traverse_)
|
||||
import Test.DocTest
|
||||
|
||||
main :: IO ()
|
||||
|
|
Loading…
Reference in a new issue