Reformat servant
This commit is contained in:
parent
74cf82946e
commit
8058891299
27 changed files with 292 additions and 203 deletions
|
@ -184,6 +184,7 @@ newline: lf
|
|||
# needs to be aware of these, so it can parse the file correctly.
|
||||
#
|
||||
# No language extensions are enabled by default.
|
||||
# language_extensions:
|
||||
# - TemplateHaskell
|
||||
# - QuasiQuotes
|
||||
language_extensions:
|
||||
- FlexibleContexts
|
||||
- TemplateHaskell
|
||||
- QuasiQuotes
|
||||
|
|
|
@ -66,71 +66,75 @@ module Servant.API (
|
|||
-- * Utilities
|
||||
module Servant.Utils.Links,
|
||||
-- | Type-safe internal URIs
|
||||
|
||||
|
||||
-- * Re-exports
|
||||
If,
|
||||
SBool (..), SBoolI (..)
|
||||
) where
|
||||
|
||||
import Servant.API.Alternative ((:<|>) (..))
|
||||
import Servant.API.BasicAuth (BasicAuth,BasicAuthData(..))
|
||||
import Servant.API.Capture (Capture, Capture', CaptureAll)
|
||||
import Servant.API.ContentTypes (Accept (..), FormUrlEncoded,
|
||||
JSON,
|
||||
MimeRender (..), NoContent (NoContent),
|
||||
MimeUnrender (..), OctetStream,
|
||||
PlainText)
|
||||
import Servant.API.Description (Description, Summary)
|
||||
import Servant.API.Empty (EmptyAPI (..))
|
||||
import Servant.API.Experimental.Auth (AuthProtect)
|
||||
import Servant.API.Header (Header, Header')
|
||||
import Servant.API.HttpVersion (HttpVersion (..))
|
||||
import Servant.API.IsSecure (IsSecure (..))
|
||||
import Servant.API.Modifiers (Required, Optional, Lenient, Strict)
|
||||
import Servant.API.QueryParam (QueryFlag, QueryParam, QueryParam',
|
||||
QueryParams)
|
||||
import Servant.API.Raw (Raw)
|
||||
import Servant.API.Stream (Stream, StreamGet, StreamPost,
|
||||
StreamGenerator (..),
|
||||
ToStreamGenerator (..),
|
||||
ResultStream(..), BuildFromStream (..),
|
||||
ByteStringParser (..),
|
||||
FramingRender (..), BoundaryStrategy (..),
|
||||
FramingUnrender (..),
|
||||
NewlineFraming,
|
||||
NetstringFraming)
|
||||
import Servant.API.RemoteHost (RemoteHost)
|
||||
import Servant.API.ReqBody (ReqBody, ReqBody')
|
||||
import Servant.API.ResponseHeaders (AddHeader, addHeader, noHeader,
|
||||
BuildHeadersTo (buildHeadersTo),
|
||||
GetHeaders (getHeaders),
|
||||
HList (..), Headers (..),
|
||||
getHeadersHList, getResponse, ResponseHeader (..))
|
||||
import Servant.API.Sub ((:>))
|
||||
import Servant.API.Vault (Vault)
|
||||
import Servant.API.Verbs (PostCreated, Delete, DeleteAccepted,
|
||||
DeleteNoContent,
|
||||
DeleteNonAuthoritative, Get,
|
||||
GetAccepted, GetNoContent,
|
||||
GetNonAuthoritative,
|
||||
GetPartialContent,
|
||||
GetResetContent,
|
||||
Patch,
|
||||
PatchAccepted, PatchNoContent,
|
||||
PatchNoContent,
|
||||
PatchNonAuthoritative, Post,
|
||||
PostAccepted, PostNoContent,
|
||||
PostNonAuthoritative,
|
||||
PostResetContent, Put,
|
||||
PutAccepted, PutNoContent,
|
||||
PutNoContent, PutNonAuthoritative,
|
||||
ReflectMethod (reflectMethod),
|
||||
Verb, StdMethod(..))
|
||||
import Servant.API.WithNamedContext (WithNamedContext)
|
||||
import Servant.Utils.Links (HasLink (..), Link, IsElem, IsElem',
|
||||
URI (..), safeLink)
|
||||
import Web.HttpApiData (FromHttpApiData (..),
|
||||
ToHttpApiData (..))
|
||||
|
||||
import Data.Type.Bool (If)
|
||||
import Data.Singletons.Bool (SBool (..), SBoolI (..))
|
||||
import Data.Singletons.Bool
|
||||
(SBool (..), SBoolI (..))
|
||||
import Data.Type.Bool
|
||||
(If)
|
||||
import Servant.API.Alternative
|
||||
((:<|>) (..))
|
||||
import Servant.API.BasicAuth
|
||||
(BasicAuth, BasicAuthData (..))
|
||||
import Servant.API.Capture
|
||||
(Capture, Capture', CaptureAll)
|
||||
import Servant.API.ContentTypes
|
||||
(Accept (..), FormUrlEncoded, JSON, MimeRender (..),
|
||||
MimeUnrender (..), NoContent (NoContent), OctetStream,
|
||||
PlainText)
|
||||
import Servant.API.Description
|
||||
(Description, Summary)
|
||||
import Servant.API.Empty
|
||||
(EmptyAPI (..))
|
||||
import Servant.API.Experimental.Auth
|
||||
(AuthProtect)
|
||||
import Servant.API.Header
|
||||
(Header, Header')
|
||||
import Servant.API.HttpVersion
|
||||
(HttpVersion (..))
|
||||
import Servant.API.IsSecure
|
||||
(IsSecure (..))
|
||||
import Servant.API.Modifiers
|
||||
(Lenient, Optional, Required, Strict)
|
||||
import Servant.API.QueryParam
|
||||
(QueryFlag, QueryParam, QueryParam', QueryParams)
|
||||
import Servant.API.Raw
|
||||
(Raw)
|
||||
import Servant.API.RemoteHost
|
||||
(RemoteHost)
|
||||
import Servant.API.ReqBody
|
||||
(ReqBody, ReqBody')
|
||||
import Servant.API.ResponseHeaders
|
||||
(AddHeader, BuildHeadersTo (buildHeadersTo),
|
||||
GetHeaders (getHeaders), HList (..), Headers (..),
|
||||
ResponseHeader (..), addHeader, getHeadersHList, getResponse,
|
||||
noHeader)
|
||||
import Servant.API.Stream
|
||||
(BoundaryStrategy (..), BuildFromStream (..),
|
||||
ByteStringParser (..), FramingRender (..),
|
||||
FramingUnrender (..), NetstringFraming, NewlineFraming,
|
||||
ResultStream (..), Stream, StreamGenerator (..), StreamGet,
|
||||
StreamPost, ToStreamGenerator (..))
|
||||
import Servant.API.Sub
|
||||
((:>))
|
||||
import Servant.API.Vault
|
||||
(Vault)
|
||||
import Servant.API.Verbs
|
||||
(Delete, DeleteAccepted, DeleteNoContent,
|
||||
DeleteNonAuthoritative, Get, GetAccepted, GetNoContent,
|
||||
GetNonAuthoritative, GetPartialContent, GetResetContent,
|
||||
Patch, PatchAccepted, PatchNoContent, PatchNonAuthoritative,
|
||||
Post, PostAccepted, PostCreated, PostNoContent,
|
||||
PostNonAuthoritative, PostResetContent, Put, PutAccepted,
|
||||
PutNoContent, PutNonAuthoritative,
|
||||
ReflectMethod (reflectMethod), StdMethod (..), Verb)
|
||||
import Servant.API.WithNamedContext
|
||||
(WithNamedContext)
|
||||
import Servant.Utils.Links
|
||||
(HasLink (..), IsElem, IsElem', Link, URI (..), safeLink)
|
||||
import Web.HttpApiData
|
||||
(FromHttpApiData (..), ToHttpApiData (..))
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE DeriveFunctor #-}
|
||||
{-# LANGUAGE DeriveFoldable #-}
|
||||
{-# LANGUAGE DeriveFunctor #-}
|
||||
{-# LANGUAGE DeriveTraversable #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# OPTIONS_HADDOCK not-home #-}
|
||||
module Servant.API.Alternative ((:<|>)(..)) where
|
||||
|
||||
import Data.Semigroup (Semigroup (..))
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Semigroup
|
||||
(Semigroup (..))
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
|
||||
module Servant.API.BasicAuth where
|
||||
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.Typeable (Typeable)
|
||||
import GHC.TypeLits (Symbol)
|
||||
import Data.ByteString
|
||||
(ByteString)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import GHC.TypeLits
|
||||
(Symbol)
|
||||
|
||||
|
||||
-- | Combinator for <https://tools.ietf.org/html/rfc2617#section-2 Basic Access Authentication>.
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
{-# OPTIONS_HADDOCK not-home #-}
|
||||
module Servant.API.Capture (Capture, Capture', CaptureAll) where
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import GHC.TypeLits (Symbol)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import GHC.TypeLits
|
||||
(Symbol)
|
||||
-- | Capture a value from the request path under a certain type @a@.
|
||||
--
|
||||
-- Example:
|
||||
|
|
|
@ -71,32 +71,38 @@ module Servant.API.ContentTypes
|
|||
, canHandleAcceptH
|
||||
) where
|
||||
|
||||
import Control.Arrow (left)
|
||||
import Control.Arrow
|
||||
(left)
|
||||
import Control.Monad.Compat
|
||||
import Data.Aeson (FromJSON(..), ToJSON(..), encode)
|
||||
import Data.Aeson.Parser (value)
|
||||
import Data.Aeson.Types (parseEither)
|
||||
import Data.Attoparsec.ByteString.Char8 (endOfInput, parseOnly,
|
||||
skipSpace, (<?>))
|
||||
import Data.Aeson
|
||||
(FromJSON (..), ToJSON (..), encode)
|
||||
import Data.Aeson.Parser
|
||||
(value)
|
||||
import Data.Aeson.Types
|
||||
(parseEither)
|
||||
import Data.Attoparsec.ByteString.Char8
|
||||
(endOfInput, parseOnly, skipSpace, (<?>))
|
||||
import qualified Data.ByteString as BS
|
||||
import Data.ByteString.Lazy (ByteString, fromStrict,
|
||||
toStrict)
|
||||
import Data.ByteString.Lazy
|
||||
(ByteString, fromStrict, toStrict)
|
||||
import qualified Data.ByteString.Lazy.Char8 as BC
|
||||
import qualified Data.List.NonEmpty as NE
|
||||
import Data.Maybe (isJust)
|
||||
import Data.String.Conversions (cs)
|
||||
import Data.Maybe
|
||||
(isJust)
|
||||
import Data.String.Conversions
|
||||
(cs)
|
||||
import qualified Data.Text as TextS
|
||||
import qualified Data.Text.Encoding as TextS
|
||||
import qualified Data.Text.Lazy as TextL
|
||||
import qualified Data.Text.Lazy.Encoding as TextL
|
||||
import Data.Typeable
|
||||
import GHC.Generics (Generic)
|
||||
import GHC.Generics
|
||||
(Generic)
|
||||
import qualified Network.HTTP.Media as M
|
||||
import Web.FormUrlEncoded (FromForm, ToForm,
|
||||
urlEncodeAsForm,
|
||||
urlDecodeAsForm)
|
||||
import Prelude ()
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
import Web.FormUrlEncoded
|
||||
(FromForm, ToForm, urlDecodeAsForm, urlEncodeAsForm)
|
||||
|
||||
#if MIN_VERSION_base(4,9,0)
|
||||
import qualified GHC.TypeLits as TL
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# OPTIONS_HADDOCK not-home #-}
|
||||
module Servant.API.Description (
|
||||
-- * Combinators
|
||||
|
@ -16,9 +16,12 @@ module Servant.API.Description (
|
|||
reflectDescription,
|
||||
) where
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import GHC.TypeLits (Symbol, KnownSymbol, symbolVal)
|
||||
import Data.Proxy (Proxy (..))
|
||||
import Data.Proxy
|
||||
(Proxy (..))
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import GHC.TypeLits
|
||||
(KnownSymbol, Symbol, symbolVal)
|
||||
|
||||
-- | Add a short summary for (part of) API.
|
||||
--
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
{-# OPTIONS_HADDOCK not-home #-}
|
||||
module Servant.API.Empty(EmptyAPI(..)) where
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
module Servant.API.Experimental.Auth where
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
|
||||
-- | A generalized Authentication combinator. Use this if you have a
|
||||
-- non-standard authentication technique.
|
||||
|
|
|
@ -6,8 +6,10 @@ module Servant.API.Header (
|
|||
Header, Header',
|
||||
) where
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import GHC.TypeLits (Symbol)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import GHC.TypeLits
|
||||
(Symbol)
|
||||
import Servant.API.Modifiers
|
||||
|
||||
-- | Extract the given header's value as a value of type @a@.
|
||||
|
|
|
@ -3,7 +3,8 @@ module Servant.API.HttpVersion
|
|||
HttpVersion(..)
|
||||
) where
|
||||
|
||||
import Network.HTTP.Types (HttpVersion (..))
|
||||
import Network.HTTP.Types
|
||||
(HttpVersion (..))
|
||||
|
||||
-- $httpversion
|
||||
--
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
|
||||
-- | This is a module containing an API with all `Servant.API` combinators. It
|
||||
|
@ -7,7 +7,6 @@
|
|||
module Servant.API.Internal.Test.ComprehensiveAPI where
|
||||
|
||||
import Data.Proxy
|
||||
|
||||
import Servant.API
|
||||
|
||||
type GET = Get '[JSON] NoContent
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
module Servant.API.IsSecure
|
||||
( -- $issecure
|
||||
IsSecure(..)
|
||||
) where
|
||||
|
||||
import Data.Typeable
|
||||
import GHC.Generics (Generic)
|
||||
(Typeable)
|
||||
import GHC.Generics
|
||||
(Generic)
|
||||
|
||||
-- | Was this request made over an SSL connection?
|
||||
--
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
|
@ -19,10 +19,14 @@ module Servant.API.Modifiers (
|
|||
unfoldRequestArgument,
|
||||
) where
|
||||
|
||||
import Data.Proxy (Proxy (..))
|
||||
import Data.Singletons.Bool (SBool (..), SBoolI (..))
|
||||
import Data.Text (Text)
|
||||
import Data.Type.Bool (If)
|
||||
import Data.Proxy
|
||||
(Proxy (..))
|
||||
import Data.Singletons.Bool
|
||||
(SBool (..), SBoolI (..))
|
||||
import Data.Text
|
||||
(Text)
|
||||
import Data.Type.Bool
|
||||
(If)
|
||||
|
||||
-- | Required argument. Not wrapped.
|
||||
data Required
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# OPTIONS_HADDOCK not-home #-}
|
||||
module Servant.API.QueryParam (QueryFlag, QueryParam, QueryParam', QueryParams) where
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import GHC.TypeLits (Symbol)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import GHC.TypeLits
|
||||
(Symbol)
|
||||
import Servant.API.Modifiers
|
||||
|
||||
-- | Lookup the value associated to the @sym@ query string parameter
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
{-# OPTIONS_HADDOCK not-home #-}
|
||||
module Servant.API.Raw where
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
|
||||
-- | Endpoint for plugging in your own Wai 'Application's.
|
||||
--
|
||||
-- The given 'Application' will get the request as received by the server, potentially with
|
||||
|
|
|
@ -5,6 +5,7 @@ module Servant.API.RemoteHost
|
|||
) where
|
||||
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
|
||||
-- | Provides access to the host or IP address
|
||||
-- from which the HTTP request was sent.
|
||||
|
|
|
@ -6,8 +6,9 @@ module Servant.API.ReqBody (
|
|||
ReqBody, ReqBody',
|
||||
) where
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import Servant.API.Modifiers
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import Servant.API.Modifiers
|
||||
|
||||
-- | Extract the request body as a value of type @a@.
|
||||
--
|
||||
|
@ -17,7 +18,7 @@ import Servant.API.Modifiers
|
|||
-- >>> type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book
|
||||
type ReqBody = ReqBody' '[Required, Strict]
|
||||
|
||||
-- |
|
||||
-- |
|
||||
--
|
||||
-- /Note:/ 'ReqBody'' is always 'Required'.
|
||||
data ReqBody' (mods :: [*]) (contentTypes :: [*]) (a :: *)
|
||||
|
|
|
@ -34,18 +34,22 @@ module Servant.API.ResponseHeaders
|
|||
, HList(..)
|
||||
) where
|
||||
|
||||
import Data.ByteString.Char8 as BS (ByteString, pack, unlines, init)
|
||||
import Data.Typeable (Typeable)
|
||||
import Web.HttpApiData (ToHttpApiData, toHeader,
|
||||
FromHttpApiData, parseHeader)
|
||||
import qualified Data.CaseInsensitive as CI
|
||||
import Data.ByteString.Char8 as BS
|
||||
(ByteString, init, pack, unlines)
|
||||
import qualified Data.CaseInsensitive as CI
|
||||
import Data.Proxy
|
||||
import GHC.TypeLits (KnownSymbol, Symbol, symbolVal)
|
||||
import qualified Network.HTTP.Types.Header as HTTP
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import GHC.TypeLits
|
||||
(KnownSymbol, Symbol, symbolVal)
|
||||
import qualified Network.HTTP.Types.Header as HTTP
|
||||
import Web.HttpApiData
|
||||
(FromHttpApiData, ToHttpApiData, parseHeader, toHeader)
|
||||
|
||||
import Servant.API.Header (Header)
|
||||
import Prelude ()
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
import Servant.API.Header
|
||||
(Header)
|
||||
|
||||
-- | Response Header objects. You should never need to construct one directly.
|
||||
-- Instead, use 'addOptionalHeader'.
|
||||
|
|
|
@ -1,26 +1,34 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# OPTIONS_HADDOCK not-home #-}
|
||||
|
||||
module Servant.API.Stream where
|
||||
|
||||
import Data.ByteString.Lazy (ByteString, empty)
|
||||
import qualified Data.ByteString.Lazy.Char8 as LB
|
||||
import Data.Monoid ((<>))
|
||||
import Data.Proxy (Proxy)
|
||||
import Data.Typeable (Typeable)
|
||||
import GHC.Generics (Generic)
|
||||
import Text.Read (readMaybe)
|
||||
import Control.Arrow (first)
|
||||
import Network.HTTP.Types.Method (StdMethod (..))
|
||||
import Control.Arrow
|
||||
(first)
|
||||
import Data.ByteString.Lazy
|
||||
(ByteString, empty)
|
||||
import qualified Data.ByteString.Lazy.Char8 as LB
|
||||
import Data.Monoid
|
||||
((<>))
|
||||
import Data.Proxy
|
||||
(Proxy)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import GHC.Generics
|
||||
(Generic)
|
||||
import Network.HTTP.Types.Method
|
||||
(StdMethod (..))
|
||||
import Text.Read
|
||||
(readMaybe)
|
||||
|
||||
-- | A Stream endpoint for a given method emits a stream of encoded values at a given Content-Type, delimited by a framing strategy. Steam endpoints always return response code 200 on success. Type synonyms are provided for standard methods.
|
||||
data Stream (method :: k1) (framing :: *) (contentType :: *) (a :: *)
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
{-# OPTIONS_HADDOCK not-home #-}
|
||||
module Servant.API.Sub ((:>)) where
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
|
||||
-- | The contained API (second argument) can be found under @("/" ++ path)@
|
||||
-- (path being the first argument).
|
||||
|
|
|
@ -47,16 +47,25 @@ module Servant.API.TypeLevel (
|
|||
) where
|
||||
|
||||
|
||||
import GHC.Exts (Constraint)
|
||||
import Servant.API.Alternative (type (:<|>))
|
||||
import Servant.API.Capture (Capture, CaptureAll)
|
||||
import Servant.API.Header (Header)
|
||||
import Servant.API.QueryParam (QueryFlag, QueryParam, QueryParams)
|
||||
import Servant.API.ReqBody (ReqBody)
|
||||
import Servant.API.Sub (type (:>))
|
||||
import Servant.API.Verbs (Verb)
|
||||
import GHC.Exts
|
||||
(Constraint)
|
||||
import Servant.API.Alternative
|
||||
(type (:<|>))
|
||||
import Servant.API.Capture
|
||||
(Capture, CaptureAll)
|
||||
import Servant.API.Header
|
||||
(Header)
|
||||
import Servant.API.QueryParam
|
||||
(QueryFlag, QueryParam, QueryParams)
|
||||
import Servant.API.ReqBody
|
||||
(ReqBody)
|
||||
import Servant.API.Sub
|
||||
(type (:>))
|
||||
import Servant.API.Verbs
|
||||
(Verb)
|
||||
#if MIN_VERSION_base(4,9,0)
|
||||
import GHC.TypeLits (TypeError, ErrorMessage(..))
|
||||
import GHC.TypeLits
|
||||
(ErrorMessage (..), TypeError)
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@ module Servant.API.Vault
|
|||
Vault
|
||||
) where
|
||||
|
||||
import Data.Vault.Lazy (Vault)
|
||||
import Data.Vault.Lazy
|
||||
(Vault)
|
||||
|
||||
-- $vault
|
||||
--
|
||||
|
|
|
@ -8,15 +8,18 @@ module Servant.API.Verbs
|
|||
, StdMethod(GET, POST, HEAD, PUT, DELETE, TRACE, CONNECT, OPTIONS, PATCH)
|
||||
) where
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Proxy (Proxy)
|
||||
import GHC.Generics (Generic)
|
||||
import GHC.TypeLits (Nat)
|
||||
import Network.HTTP.Types.Method (Method, StdMethod (..),
|
||||
methodDelete, methodGet, methodHead,
|
||||
methodPatch, methodPost, methodPut,
|
||||
methodTrace, methodConnect,
|
||||
methodOptions)
|
||||
import Data.Proxy
|
||||
(Proxy)
|
||||
import Data.Typeable
|
||||
(Typeable)
|
||||
import GHC.Generics
|
||||
(Generic)
|
||||
import GHC.TypeLits
|
||||
(Nat)
|
||||
import Network.HTTP.Types.Method
|
||||
(Method, StdMethod (..), methodConnect, methodDelete,
|
||||
methodGet, methodHead, methodOptions, methodPatch, methodPost,
|
||||
methodPut, methodTrace)
|
||||
|
||||
-- | @Verb@ is a general type for representing HTTP verbs (a.k.a. methods). For
|
||||
-- convenience, type synonyms for each verb with a 200 response code are
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
|
||||
module Servant.API.WithNamedContext where
|
||||
|
||||
import GHC.TypeLits
|
||||
import GHC.TypeLits
|
||||
|
||||
-- | 'WithNamedContext' names a specific tagged context to use for the
|
||||
-- combinators in the API. (See also in @servant-server@,
|
||||
|
|
|
@ -13,7 +13,6 @@ module Servant.Utils.Enter {-# DEPRECATED "Use hoistServer or hoistServerWithCon
|
|||
(:~>)(..),
|
||||
) where
|
||||
|
||||
import Control.Natural
|
||||
import Control.Monad.Identity
|
||||
import Control.Monad.Morph
|
||||
import Control.Monad.Reader
|
||||
|
@ -21,8 +20,10 @@ import qualified Control.Monad.State.Lazy as LState
|
|||
import qualified Control.Monad.State.Strict as SState
|
||||
import qualified Control.Monad.Writer.Lazy as LWriter
|
||||
import qualified Control.Monad.Writer.Strict as SWriter
|
||||
import Data.Tagged (Tagged, retag)
|
||||
import Prelude ()
|
||||
import Control.Natural
|
||||
import Data.Tagged
|
||||
(Tagged, retag)
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
import Servant.API
|
||||
|
||||
|
|
|
@ -101,38 +101,63 @@ module Servant.Utils.Links (
|
|||
) where
|
||||
|
||||
import Data.List
|
||||
import Data.Monoid.Compat ( (<>) )
|
||||
import Data.Proxy ( Proxy(..) )
|
||||
import Data.Singletons.Bool ( SBool (..), SBoolI (..) )
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.Text.Encoding as TE
|
||||
import Data.Type.Bool (If)
|
||||
import GHC.TypeLits ( KnownSymbol, symbolVal )
|
||||
import Network.URI ( URI(..), escapeURIString, isUnreserved )
|
||||
import Prelude ()
|
||||
import Data.Monoid.Compat
|
||||
((<>))
|
||||
import Data.Proxy
|
||||
(Proxy (..))
|
||||
import Data.Singletons.Bool
|
||||
(SBool (..), SBoolI (..))
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.Text.Encoding as TE
|
||||
import Data.Type.Bool
|
||||
(If)
|
||||
import GHC.TypeLits
|
||||
(KnownSymbol, symbolVal)
|
||||
import Network.URI
|
||||
(URI (..), escapeURIString, isUnreserved)
|
||||
import Prelude ()
|
||||
import Prelude.Compat
|
||||
|
||||
import Web.HttpApiData
|
||||
import Servant.API.Alternative ( (:<|>)((:<|>)) )
|
||||
import Servant.API.BasicAuth ( BasicAuth )
|
||||
import Servant.API.Capture ( Capture', CaptureAll )
|
||||
import Servant.API.ReqBody ( ReqBody' )
|
||||
import Servant.API.QueryParam ( QueryParam', QueryParams, QueryFlag )
|
||||
import Servant.API.Header ( Header' )
|
||||
import Servant.API.HttpVersion (HttpVersion)
|
||||
import Servant.API.RemoteHost ( RemoteHost )
|
||||
import Servant.API.IsSecure (IsSecure)
|
||||
import Servant.API.Empty (EmptyAPI (..))
|
||||
import Servant.API.Verbs ( Verb )
|
||||
import Servant.API.Sub ( type (:>) )
|
||||
import Servant.API.Raw ( Raw )
|
||||
import Servant.API.Stream ( Stream )
|
||||
import Servant.API.TypeLevel
|
||||
import Servant.API.Modifiers (FoldRequired)
|
||||
import Servant.API.Description (Description, Summary)
|
||||
import Servant.API.Vault (Vault)
|
||||
import Servant.API.WithNamedContext (WithNamedContext)
|
||||
import Servant.API.Experimental.Auth ( AuthProtect )
|
||||
import Servant.API.Alternative
|
||||
((:<|>) ((:<|>)))
|
||||
import Servant.API.BasicAuth
|
||||
(BasicAuth)
|
||||
import Servant.API.Capture
|
||||
(Capture', CaptureAll)
|
||||
import Servant.API.Description
|
||||
(Description, Summary)
|
||||
import Servant.API.Empty
|
||||
(EmptyAPI (..))
|
||||
import Servant.API.Experimental.Auth
|
||||
(AuthProtect)
|
||||
import Servant.API.Header
|
||||
(Header')
|
||||
import Servant.API.HttpVersion
|
||||
(HttpVersion)
|
||||
import Servant.API.IsSecure
|
||||
(IsSecure)
|
||||
import Servant.API.Modifiers
|
||||
(FoldRequired)
|
||||
import Servant.API.QueryParam
|
||||
(QueryFlag, QueryParam', QueryParams)
|
||||
import Servant.API.Raw
|
||||
(Raw)
|
||||
import Servant.API.RemoteHost
|
||||
(RemoteHost)
|
||||
import Servant.API.ReqBody
|
||||
(ReqBody')
|
||||
import Servant.API.Stream
|
||||
(Stream)
|
||||
import Servant.API.Sub
|
||||
(type (:>))
|
||||
import Servant.API.TypeLevel
|
||||
import Servant.API.Vault
|
||||
(Vault)
|
||||
import Servant.API.Verbs
|
||||
(Verb)
|
||||
import Servant.API.WithNamedContext
|
||||
(WithNamedContext)
|
||||
import Web.HttpApiData
|
||||
|
||||
-- | A safe link datatype.
|
||||
-- The only way of constructing a 'Link' is using 'safeLink', which means any
|
||||
|
|
Loading…
Reference in a new issue