Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class ToHttpApiData a
- class FromHttpApiData a where
- parseUrlPiece :: Text -> Either Text a
- parseHeader :: ByteString -> Either Text a
- parseQueryParam :: Text -> Either Text a
- type Get = Verb 'GET 200
- type Post = Verb 'POST 200
- type Put = Verb 'PUT 200
- type Delete = Verb 'DELETE 200
- type GetNoContent = NoContentVerb 'GET
- type PostNoContent = NoContentVerb 'POST
- type DeleteNoContent = NoContentVerb 'DELETE
- type PutNoContent = NoContentVerb 'PUT
- data (path :: k) :> a
- type ReqBody = ReqBody' '[Required, Strict]
- data NoContent = NoContent
- data a :<|> b = a :<|> b
- type HttpDescription = Description
- type HttpJson = JSON
- type HttpSummary = Summary
Servant re-exports
class ToHttpApiData a #
Convert value to HTTP API data.
WARNING: Do not derive this using DeriveAnyClass
as the generated
instance will loop indefinitely.
Instances
class FromHttpApiData a where #
Parse value from HTTP API data.
WARNING: Do not derive this using DeriveAnyClass
as the generated
instance will loop indefinitely.
parseUrlPiece :: Text -> Either Text a #
Parse URL path piece.
parseHeader :: ByteString -> Either Text a #
Parse HTTP header value.
parseQueryParam :: Text -> Either Text a #
Parse query param value.
Instances
type GetNoContent = NoContentVerb 'GET #
GET
with 204 status code.
type PostNoContent = NoContentVerb 'POST #
POST
with 204 status code.
type DeleteNoContent = NoContentVerb 'DELETE #
DELETE
with 204 status code.
type PutNoContent = NoContentVerb 'PUT #
PUT
with 204 status code.
data (path :: k) :> a infixr 4 #
The contained API (second argument) can be found under ("/" ++ path)
(path being the first argument).
Example:
>>>
-- GET /hello/world
>>>
-- returning a JSON encoded World value
>>>
type MyApi = "hello" :> "world" :> Get '[JSON] World
Instances
type ReqBody = ReqBody' '[Required, Strict] #
Extract the request body as a value of type a
.
Example:
>>>
-- POST /books
>>>
type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book
A type for responses without content-body.
Instances
Generic NoContent | |
Read NoContent | |
Show NoContent | |
NFData NoContent | |
Defined in Servant.API.ContentTypes | |
Eq NoContent | |
HasStatus NoContent | If an API can respond with |
Defined in Servant.API.UVerb | |
AllMime (ctyp ': (ctyp' ': ctyps)) => AllMimeRender (ctyp ': (ctyp' ': ctyps)) NoContent | |
Defined in Servant.API.ContentTypes allMimeRender :: Proxy (ctyp ': (ctyp' ': ctyps)) -> NoContent -> [(MediaType, ByteString)] # | |
Accept ctyp => AllMimeRender '[ctyp] NoContent | |
Defined in Servant.API.ContentTypes allMimeRender :: Proxy '[ctyp] -> NoContent -> [(MediaType, ByteString)] # | |
type Rep NoContent | |
type StatusOf NoContent | |
Defined in Servant.API.UVerb |
Union of two APIs, first takes precedence in case of overlap.
Example:
>>>
:{
type MyApi = "books" :> Get '[JSON] [Book] -- GET /books :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] () -- POST /books :}
a :<|> b infixr 3 |
Instances
Bifoldable (:<|>) | |
Bifunctor (:<|>) | |
Bitraversable (:<|>) | |
Defined in Servant.API.Alternative bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> (a :<|> b) -> f (c :<|> d) # | |
Biapplicative (:<|>) | |
Defined in Servant.API.Alternative | |
(HasLink a, HasLink b) => HasLink (a :<|> b :: Type) | |
Foldable ((:<|>) a) | |
Defined in Servant.API.Alternative fold :: Monoid m => (a :<|> m) -> m # foldMap :: Monoid m => (a0 -> m) -> (a :<|> a0) -> m # foldMap' :: Monoid m => (a0 -> m) -> (a :<|> a0) -> m # foldr :: (a0 -> b -> b) -> b -> (a :<|> a0) -> b # foldr' :: (a0 -> b -> b) -> b -> (a :<|> a0) -> b # foldl :: (b -> a0 -> b) -> b -> (a :<|> a0) -> b # foldl' :: (b -> a0 -> b) -> b -> (a :<|> a0) -> b # foldr1 :: (a0 -> a0 -> a0) -> (a :<|> a0) -> a0 # foldl1 :: (a0 -> a0 -> a0) -> (a :<|> a0) -> a0 # toList :: (a :<|> a0) -> [a0] # length :: (a :<|> a0) -> Int # elem :: Eq a0 => a0 -> (a :<|> a0) -> Bool # maximum :: Ord a0 => (a :<|> a0) -> a0 # minimum :: Ord a0 => (a :<|> a0) -> a0 # | |
Traversable ((:<|>) a) | |
Functor ((:<|>) a) | |
(Monoid a, Monoid b) => Monoid (a :<|> b) | |
(Semigroup a, Semigroup b) => Semigroup (a :<|> b) | |
(Bounded a, Bounded b) => Bounded (a :<|> b) | |
(Show a, Show b) => Show (a :<|> b) | |
(Eq a, Eq b) => Eq (a :<|> b) | |
type MkLink (a :<|> b :: Type) r | |
Alias types
type HttpDescription = Description Source #
type HttpSummary = Summary Source #