Moduleservant-0.20.2 Haskell2010
Servant.API. Generic
Define servant servers from record types. Generics for the win.
The usage is simple, if you only need a collection of routes. First you
define a record with field types prefixed by a parameter route:
data Routes route = Routes
{ _get :: route :- Capture "id" Int :> Get '[JSON] String
, _put :: route :- ReqBody '[JSON] Int :> Put '[JSON] Bool
}
deriving (Generic )
You can get a Proxy of the server using
api :: Proxy (ToServantApi Routes)
api = genericApi (Proxy :: Proxy Routes)
Using genericApi is better as it checks that instances exists,
i.e. you get better error messages than simply using Proxy value.
Note: in 0.14 series this module isn't re-exported from Servant.API.
Servant.API.Generic is based on servant-generic package by
Patrick Chilton
AsApi Utility re-exports