我有一个带有 rest api 的简单服务应用程序:
type API = "items" :> Get '[JSON] [MyData]
app :: Application
app = serve api server
api :: Proxy API
api = Proxy
server :: Server API
server = getItems
getItems :: ExceptT ServantErr IO [MyData]
getItems = ......
startApp :: IO ()
startApp = run 1234 app
如何根据条件访问 http 标头并返回特定响应,例如 http403?