| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Servant.Server.Internal
- class HasServer layout context where
- type Server layout = ServerT layout Handler
- allowedMethodHead :: Method -> Request -> Bool
- allowedMethod :: Method -> Request -> Bool
- processMethodRouter :: Maybe (ByteString, ByteString) -> Status -> Method -> Maybe [(HeaderName, ByteString)] -> Request -> RouteResult Response
- methodCheck :: Method -> Request -> DelayedIO ()
- acceptCheck :: AllMime list => Proxy list -> ByteString -> DelayedIO ()
- methodRouter :: AllCTRender ctypes a => Method -> Proxy ctypes -> Status -> Delayed env (Handler a) -> Router env
- methodRouterHeaders :: (GetHeaders (Headers h v), AllCTRender ctypes v) => Method -> Proxy ctypes -> Status -> Delayed env (Handler (Headers h v)) -> Router env
- ct_wildcard :: ByteString
- module Servant.Server.Internal.Context
- module Servant.Server.Internal.BasicAuth
- module Servant.Server.Internal.Router
- module Servant.Server.Internal.RoutingApplication
- module Servant.Server.Internal.ServantErr
Documentation
class HasServer layout context where Source
Instances
| HasServer * Raw context Source | Just pass the request to the underlying application and serve its response. Example: type MyApi = "images" :> Raw server :: Server MyApi server = serveDirectory "/var/www/images" |
| (HasServer * a context, HasServer * b context) => HasServer * ((:<|>) a b) context Source | A server for type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
:<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books
server :: Server MyApi
server = listAllBooks :<|> postBook
where listAllBooks = ...
postBook book = ... |
| (HasContextEntry context (NamedContext name subContext), HasServer * subApi subContext) => HasServer * (WithNamedContext name subContext subApi) context Source | |
| (KnownSymbol realm, HasServer k api context, HasContextEntry context (BasicAuthCheck usr)) => HasServer * ((:>) * k (BasicAuth realm usr) api) context Source | Basic Authentication |
| HasServer k api context => HasServer * ((:>) * k HttpVersion api) context Source | |
| HasServer k api context => HasServer * ((:>) * k Vault api) context Source | |
| HasServer k api context => HasServer * ((:>) * k IsSecure api) context Source | |
| HasServer k api context => HasServer * ((:>) * k RemoteHost api) context Source | |
| (AllCTUnrender list a, HasServer k sublayout context) => HasServer * ((:>) * k (ReqBody * list a) sublayout) context Source | If you use All it asks is for a Example: type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book
server :: Server MyApi
server = postBook
where postBook :: Book -> Handler Book
postBook book = ...insert into your db... |
| (KnownSymbol sym, HasServer k sublayout context) => HasServer * ((:>) * k (QueryFlag sym) sublayout) context Source | If you use Example: type MyApi = "books" :> QueryFlag "published" :> Get '[JSON] [Book]
server :: Server MyApi
server = getBooks
where getBooks :: Bool -> Handler [Book]
getBooks onlyPublished = ...return all books, or only the ones that are already published, depending on the argument... |
| (KnownSymbol sym, FromHttpApiData a, HasServer k sublayout context) => HasServer * ((:>) * k (QueryParams * sym a) sublayout) context Source | If you use This lets servant worry about looking up 0 or more values in the query string
associated to You can control how the individual values are converted from Example: type MyApi = "books" :> QueryParams "authors" Text :> Get '[JSON] [Book]
server :: Server MyApi
server = getBooksBy
where getBooksBy :: [Text] -> Handler [Book]
getBooksBy authors = ...return all books by these authors... |
| (KnownSymbol sym, FromHttpApiData a, HasServer k sublayout context) => HasServer * ((:>) * k (QueryParam * sym a) sublayout) context Source | If you use This lets servant worry about looking it up in the query string
and turning it into a value of the type you specify, enclosed
in You can control how it'll be converted from Example: type MyApi = "books" :> QueryParam "author" Text :> Get '[JSON] [Book]
server :: Server MyApi
server = getBooksBy
where getBooksBy :: Maybe Text -> Handler [Book]
getBooksBy Nothing = ...return all books...
getBooksBy (Just author) = ...return books by the given author... |
| (KnownSymbol sym, FromHttpApiData a, HasServer k sublayout context) => HasServer * ((:>) * k (Header sym a) sublayout) context Source | If you use All it asks is for a Example: newtype Referer = Referer Text
deriving (Eq, Show, FromHttpApiData)
-- GET /view-my-referer
type MyApi = "view-my-referer" :> Header "Referer" Referer :> Get '[JSON] Referer
server :: Server MyApi
server = viewReferer
where viewReferer :: Referer -> Handler referer
viewReferer referer = return referer |
| (KnownSymbol capture, FromHttpApiData a, HasServer k sublayout context) => HasServer * ((:>) * k (Capture * capture a) sublayout) context Source | If you use You can control how it'll be converted from Example: type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book
server :: Server MyApi
server = getBook
where getBook :: Text -> Handler Book
getBook isbn = ... |
| (KnownSymbol path, HasServer k sublayout context) => HasServer * ((:>) Symbol k path sublayout) context Source | Make sure the incoming request starts with |
| (AllCTRender ctypes a, ReflectMethod k method, KnownNat status, GetHeaders (Headers h a)) => HasServer * (Verb k * method status ctypes (Headers h a)) context Source | |
| (AllCTRender ctypes a, ReflectMethod k method, KnownNat status) => HasServer * (Verb k * method status ctypes a) context Source |
Instances
allowedMethodHead :: Method -> Request -> Bool Source
allowedMethod :: Method -> Request -> Bool Source
processMethodRouter :: Maybe (ByteString, ByteString) -> Status -> Method -> Maybe [(HeaderName, ByteString)] -> Request -> RouteResult Response Source
methodCheck :: Method -> Request -> DelayedIO () Source
acceptCheck :: AllMime list => Proxy list -> ByteString -> DelayedIO () Source
methodRouter :: AllCTRender ctypes a => Method -> Proxy ctypes -> Status -> Delayed env (Handler a) -> Router env Source
methodRouterHeaders :: (GetHeaders (Headers h v), AllCTRender ctypes v) => Method -> Proxy ctypes -> Status -> Delayed env (Handler (Headers h v)) -> Router env Source