Add NamedRoutes combinator
Allows users to directly embed APIs defined as records of routes into vanilla Servant API types. E.g.: ```haskell data MyRoutes mode = MyRoutes { version :: mode :- Get '[JSON] Int , … } type API = "prefix" :> NamedRoutes MyRoutes :<|> … ``` APIs can thus be recursively defined directly with Generic record types.
This commit is contained in:
parent
0b706aa6d1
commit
94cccffc75
1 changed files with 5 additions and 0 deletions
|
@ -37,6 +37,8 @@ module Servant.API.Generic (
|
||||||
ToServant,
|
ToServant,
|
||||||
toServant,
|
toServant,
|
||||||
fromServant,
|
fromServant,
|
||||||
|
-- * NamedRoutes combinator
|
||||||
|
NamedRoutes,
|
||||||
-- * AsApi
|
-- * AsApi
|
||||||
AsApi,
|
AsApi,
|
||||||
ToServantApi,
|
ToServantApi,
|
||||||
|
@ -120,6 +122,9 @@ genericApi
|
||||||
-> Proxy (ToServantApi routes)
|
-> Proxy (ToServantApi routes)
|
||||||
genericApi _ = Proxy
|
genericApi _ = Proxy
|
||||||
|
|
||||||
|
-- | Combinator for embedding a record of named routes into a Servant API type.
|
||||||
|
data NamedRoutes (api :: * -> *)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Class
|
-- Class
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue