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
|
@ -13,5 +13,5 @@ module Servant.Client
|
|||
, module Servant.Client.Core.Reexport
|
||||
) where
|
||||
|
||||
import Servant.Client.Core.Reexport
|
||||
import Servant.Client.Internal.HttpClient
|
||||
import Servant.Client.Core.Reexport
|
||||
import Servant.Client.Internal.HttpClient
|
||||
|
|
|
@ -11,34 +11,49 @@
|
|||
{-# LANGUAGE TypeFamilies #-}
|
||||
module Servant.Client.Internal.HttpClient where
|
||||
|
||||
import Prelude ()
|
||||
import Prelude ()
|
||||
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
|
||||
|
|
|
@ -26,56 +26,53 @@
|
|||
#include "overlapping-compat.h"
|
||||
module Servant.ClientSpec (spec, Person(..), startWaiApp, endWaiApp) where
|
||||
|
||||
import Prelude ()
|
||||
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.Monoid ()
|
||||
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.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 ()
|
||||
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
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
import Control.Lens
|
||||
import Data.Aeson
|
||||
import Data.Proxy
|
||||
import Data.String.Conversions
|
||||
import Data.Text (Text)
|
||||
import GHC.Generics
|
||||
import Servant.API
|
||||
import Servant.Docs
|
||||
import Control.Lens
|
||||
import Data.Aeson
|
||||
import Data.Proxy
|
||||
import Data.String.Conversions
|
||||
import Data.Text
|
||||
(Text)
|
||||
import GHC.Generics
|
||||
import Servant.API
|
||||
import Servant.Docs
|
||||
|
||||
-- * Example
|
||||
|
||||
|
|
|
@ -56,5 +56,5 @@ module Servant.Docs
|
|||
, single
|
||||
) where
|
||||
|
||||
import Servant.Docs.Internal
|
||||
import Servant.Docs.Internal.Pretty
|
||||
import Servant.Docs.Internal
|
||||
import Servant.Docs.Internal.Pretty
|
||||
|
|
|
@ -20,33 +20,45 @@
|
|||
#include "overlapping-compat.h"
|
||||
module Servant.Docs.Internal where
|
||||
|
||||
import Prelude ()
|
||||
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 (..),
|
||||
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.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 GHC.Generics
|
||||
import GHC.TypeLits
|
||||
import Servant.API
|
||||
|
|
|
@ -4,16 +4,20 @@
|
|||
{-# 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 Servant.API
|
||||
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.
|
||||
data PrettyJSON
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
import Distribution.Simple
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
||||
|
|
|
@ -51,6 +51,6 @@ module Servant.Foreign
|
|||
, module Servant.Foreign.Inflections
|
||||
) where
|
||||
|
||||
import Servant.API
|
||||
import Servant.Foreign.Internal
|
||||
import Servant.Foreign.Inflections
|
||||
import Servant.API
|
||||
import Servant.Foreign.Inflections
|
||||
import Servant.Foreign.Internal
|
||||
|
|
|
@ -10,11 +10,14 @@ module Servant.Foreign.Inflections
|
|||
) where
|
||||
|
||||
|
||||
import Control.Lens hiding (cons)
|
||||
import qualified Data.Char as C
|
||||
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
|
||||
|
|
|
@ -1,42 +1,47 @@
|
|||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
#if !MIN_VERSION_base(4,8,0)
|
||||
{-# LANGUAGE NullaryTypeClasses #-}
|
||||
{-# LANGUAGE NullaryTypeClasses #-}
|
||||
#endif
|
||||
|
||||
-- | Generalizes all the data needed to make code generation work with
|
||||
-- arbitrary programming languages.
|
||||
module Servant.Foreign.Internal where
|
||||
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
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 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)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
#if __GLASGOW_HASKELL__ < 709
|
||||
{-# OPTIONS_GHC -fcontext-stack=41 #-}
|
||||
#endif
|
||||
|
@ -16,12 +16,13 @@
|
|||
|
||||
module Servant.ForeignSpec where
|
||||
|
||||
import Data.Monoid ((<>))
|
||||
import Data.Proxy
|
||||
import Servant.Foreign
|
||||
import Servant.API.Internal.Test.ComprehensiveAPI
|
||||
import Data.Monoid
|
||||
((<>))
|
||||
import Data.Proxy
|
||||
import Servant.API.Internal.Test.ComprehensiveAPI
|
||||
import Servant.Foreign
|
||||
|
||||
import Test.Hspec
|
||||
import Test.Hspec
|
||||
|
||||
|
||||
spec :: Spec
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
|
||||
-- | This module lets you implement 'Server's for defined APIs. You'll
|
||||
-- most likely just need 'serve'.
|
||||
|
@ -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,33 +1,37 @@
|
|||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -1,27 +1,23 @@
|
|||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
|
||||
#if MIN_VERSION_base(4,9,0) && __GLASGOW_HASKELL__ >= 802
|
||||
#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 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 qualified Data.Text as T
|
||||
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.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 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 Prelude ()
|
||||
import GHC.TypeLits
|
||||
(KnownNat, KnownSymbol, natVal, symbolVal)
|
||||
import qualified Network.HTTP.Media as NHM
|
||||
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
|
||||
|
|
|
@ -1,22 +1,31 @@
|
|||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE DeriveFunctor #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE DeriveFunctor #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Servant.Server.Internal.BasicAuth where
|
||||
|
||||
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 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 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
|
||||
|
||||
|
|
|
@ -5,17 +5,25 @@
|
|||
{-# LANGUAGE TypeFamilies #-}
|
||||
module Servant.Server.Internal.Handler where
|
||||
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
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 GADTs #-}
|
||||
{-# 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,16 +10,25 @@
|
|||
{-# 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 (..),
|
||||
defaultLiftBaseWith, defaultRestoreM)
|
||||
import Control.Monad.Trans.Resource (MonadResource (..), ResourceT, runResourceT, transResourceT, withInternalState, runInternalState)
|
||||
import Network.Wai (Application, Request, Response, ResponseReceived)
|
||||
import Prelude ()
|
||||
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, runInternalState,
|
||||
runResourceT, transResourceT, withInternalState)
|
||||
import Network.Wai
|
||||
(Application, Request, Response, ResponseReceived)
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
import Servant.Server.Internal.Handler
|
||||
import Servant.Server.Internal.ServantErr
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
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
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
module Servant.HoistSpec where
|
||||
|
||||
import Test.Hspec (Spec)
|
||||
import Test.Hspec
|
||||
(Spec)
|
||||
|
||||
import Servant
|
||||
import Servant
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- https://github.com/haskell-servant/servant/issues/734
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,31 +1,37 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
module Servant.Server.Internal.RoutingApplicationSpec (spec) where
|
||||
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
|
||||
import Control.Exception hiding (Handler)
|
||||
import Control.Monad.Trans.Resource (register)
|
||||
import Control.Monad.IO.Class
|
||||
import Data.IORef
|
||||
import Data.Proxy
|
||||
import GHC.TypeLits (Symbol, KnownSymbol, symbolVal)
|
||||
import Servant
|
||||
import Servant.Server.Internal.RoutingApplication
|
||||
import Network.Wai (defaultRequest)
|
||||
import Test.Hspec
|
||||
import Test.Hspec.Wai (request, shouldRespondWith, with)
|
||||
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
|
||||
(KnownSymbol, Symbol, symbolVal)
|
||||
import Network.Wai
|
||||
(defaultRequest)
|
||||
import Servant
|
||||
import Servant.Server.Internal.RoutingApplication
|
||||
import Test.Hspec
|
||||
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
|
||||
= TestResourceNone
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# 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
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
|
||||
-- | This module tests whether streaming works from client to server
|
||||
-- with a server implemented with servant-server.
|
||||
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
|
||||
import qualified Data.ByteString as Strict
|
||||
import qualified Data.ByteString.Lazy as Lazy
|
||||
import Network.HTTP.Types
|
||||
import Network.Wai
|
||||
import Network.Wai.Internal
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
|
||||
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
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
|
||||
-- | These are custom combinators for Servant.Server.UsingContextSpec.
|
||||
--
|
||||
|
|
|
@ -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,9 +13,11 @@
|
|||
-----------------------------------------------------------------------------
|
||||
module Main where
|
||||
|
||||
import Build_doctests (flags, pkgs, module_sources)
|
||||
import Data.Foldable (traverse_)
|
||||
import Test.DocTest
|
||||
import Build_doctests
|
||||
(flags, module_sources, pkgs)
|
||||
import Data.Foldable
|
||||
(traverse_)
|
||||
import Test.DocTest
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,4 +3,4 @@ module Servant.Utils.Links
|
|||
( module Servant.Links )
|
||||
where
|
||||
|
||||
import Servant.Links
|
||||
import Servant.Links
|
||||
|
|
|
@ -12,25 +12,32 @@ import Prelude ()
|
|||
import Prelude.Compat
|
||||
|
||||
import Data.Aeson.Compat
|
||||
import Data.ByteString.Char8 (ByteString, append, pack)
|
||||
import qualified Data.ByteString.Lazy as BSL
|
||||
import qualified Data.ByteString.Lazy.Char8 as BSL8
|
||||
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 qualified Data.List.NonEmpty as NE
|
||||
import Data.Maybe (fromJust, isJust, isNothing)
|
||||
import Data.Function
|
||||
(on)
|
||||
import Data.List
|
||||
(maximumBy)
|
||||
import qualified Data.List.NonEmpty as NE
|
||||
import Data.Maybe
|
||||
(fromJust, isJust, isNothing)
|
||||
import Data.Proxy
|
||||
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 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 "quickcheck-instances" Test.QuickCheck.Instances ()
|
||||
import Text.Read
|
||||
(readMaybe)
|
||||
|
||||
import Servant.API.ContentTypes
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Servant.API.ResponseHeadersSpec where
|
||||
|
||||
import Test.Hspec
|
||||
import Test.Hspec
|
||||
|
||||
import Servant.API.Header
|
||||
import Servant.API.ResponseHeaders
|
||||
import Servant.API.Header
|
||||
import Servant.API.ResponseHeaders
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Servant.API.ResponseHeaders" $ do
|
||||
|
|
|
@ -1,22 +1,25 @@
|
|||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# 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,9 +13,11 @@
|
|||
-----------------------------------------------------------------------------
|
||||
module Main where
|
||||
|
||||
import Build_doctests (flags, pkgs, module_sources)
|
||||
import Data.Foldable (traverse_)
|
||||
import Test.DocTest
|
||||
import Build_doctests
|
||||
(flags, module_sources, pkgs)
|
||||
import Data.Foldable
|
||||
(traverse_)
|
||||
import Test.DocTest
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
|
|
Loading…
Reference in a new issue