Servant中如何为所有端点添加前缀?
How to add a prefix to all the end points in Servant?
我在 Haskell servant 中有一个 hello world 应用程序,这是它的一部分:
type API =
"my_items" :> Get '[JSON] [MyItem]
:<|> "my_items" :> Capture "id" Int :> Get '[JSON] MyItem
-- ...................
网址是:
localhost/my_items
localhost/my_items/123
如何为现有网址和我将创建的其他网址添加前缀:
localhost/api/v1/my_items
localhost/api/v1/my_items/123
localhost/api/v1/.....
?
再创建一个类型:
type APIv1 = "api" :> "v1" :> API
我在 Haskell servant 中有一个 hello world 应用程序,这是它的一部分:
type API =
"my_items" :> Get '[JSON] [MyItem]
:<|> "my_items" :> Capture "id" Int :> Get '[JSON] MyItem
-- ...................
网址是:
localhost/my_items
localhost/my_items/123
如何为现有网址和我将创建的其他网址添加前缀:
localhost/api/v1/my_items
localhost/api/v1/my_items/123
localhost/api/v1/.....
?
再创建一个类型:
type APIv1 = "api" :> "v1" :> API