servant-0.2: A family of combinators for defining webservices APIs and serving them

Safe HaskellNone
LanguageHaskell2010

Servant.API.Alternative

Synopsis

Documentation

data a :<|> b infixr 8 Source

Union of two APIs, first takes precedence in case of overlap.

Example:

type MyApi = "books" :> Get [Book] -- GET /books
        :<|> "books" :> ReqBody Book :> Post Book -- POST /books

Constructors

a :<|> b infixr 8 

Instances

(HasServer a, HasServer b) => HasServer ((:<|>) a b)

A server for a :<|> b first tries to match the request again the route represented by a and if it fails tries b. You must provide a request handler for each route.

type MyApi = "books" :> Get [Book] -- GET /books
        :<|> "books" :> ReqBody Book :> Post Book -- POST /books

server :: Server MyApi
server = listAllBooks :<|> postBook
  where listAllBooks = ...
        postBook book = ...
type Server ((:<|>) a b) = (:<|>) (Server a) (Server b)