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