Haskell 在带有服务的内部Api之前添加公共根路径
我有以下API:Haskell 在带有服务的内部Api之前添加公共根路径,haskell,servant,Haskell,Servant,我有以下API: type GSDMonitoringApi = FetchWorkspaceIdsCreated :<|> FetchGsdCommandsByWorkspaceId type FetchWorkspaceIdsCreated = "gsd" :> "monitoring" :> "workspaceIds" :> Get '[JSON] [Persisted WorkspaceId] ty
type GSDMonitoringApi = FetchWorkspaceIdsCreated
:<|> FetchGsdCommandsByWorkspaceId
type FetchWorkspaceIdsCreated = "gsd" :> "monitoring" :> "workspaceIds" :> Get '[JSON] [Persisted WorkspaceId]
type FetchGsdCommandsByWorkspaceId = "gsd" :> "monitoring" :> "commands" :> Capture "workspaceId" WorkspaceId :> Get '[JSON] [Persisted GsdCommand]
键入GSDMonitoringApi=FetchWorkspaceIdsCreated
:FetchGsdCommandsByWorkspaceId
键入FetchWorkspaceIdsCreated=“gsd”:>“监控”:>“工作空间ID”:>获取“[JSON][持久化的工作空间ID]
键入FetchGsdCommandsByWorkspaceId=“gsd”:>“监视”:>“命令”:>捕获“workspaceId”workspaceId:>获取“[JSON][持久化的GsdCommand]
是否可以将“gsd”:>“监控”:>
分解出来,并仅将其放入GSDMonitoringApi一次
附言:仆人做得非常好 是的,您可以在合并两个分支后为它们添加前缀:
type GSDMonitoringApi =
"gsd" :> "monitoring" :>
( FetchWorkspaceIdsCreated :<|> FetchGsdCommandsByWorkspaceId )
type FetchWorkspaceIdsCreated = "workspaceIds" :> Get '[JSON] [Persisted WorkspaceId]
type FetchGsdCommandsByWorkspaceId = "commands" :> Capture "workspaceId" WorkspaceId :> Get '[JSON] [Persisted GsdCommand]
类型GSDMonitoringApi=
“gsd”:>“监控”:>
(FetchWorkspaceIDCreated:FetchGsdCommandsByWorkspaceId)
键入FetchWorkspaceIdsCreated=“workspaceIds”:>获取“[JSON][persistedworkspaceid]
键入FetchGsdCommandsByWorkspaceId=“commands”:>捕获“workspaceId”workspaceId:>获取“[JSON][持久化的GsdCommand]
作为一个半相关的观点,我建议你去看看。将API与类似的
:
相结合会很快变得非常丑陋Servant.API.Generic
在某种程度上解决了这一问题。也许阅读食谱有助于理解那些haddock(以及-server,-client,…)中相应的haddock):