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
04e4de5260
commit
65e3070cac
1 changed files with 5 additions and 0 deletions
|
@ -37,6 +37,8 @@ module Servant.API.Generic (
|
|||
ToServant,
|
||||
toServant,
|
||||
fromServant,
|
||||
-- * NamedRoutes combinator
|
||||
NamedRoutes,
|
||||
-- * AsApi
|
||||
AsApi,
|
||||
ToServantApi,
|
||||
|
@ -120,6 +122,9 @@ genericApi
|
|||
-> Proxy (ToServantApi routes)
|
||||
genericApi _ = Proxy
|
||||
|
||||
-- | Combinator for embedding a record of named routes into a Servant API type.
|
||||
data NamedRoutes (api :: * -> *)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Class
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue