You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently, I tried to write a WAI Middleware that was aware of the API my application was using. In particular, given an incoming request url, I wanted to be able to tell which endpoint was used, and which parts of the url were captured.
For instance, consider the server api below:
typeApi="foo":>Capture"id"Int:>Get '[JSON, PlainText] Foo:<|>"bar":>Capture"id"Int:>Get '[JSON, PlainText] Bar
Let us request it with the following command:
curl -X GET "http://localhost/foo/12345" -H "Accept: application/json"
If the request succeeds, we should get a Foo object, encoded as JSON.
The additional data I would like to get from Servant for my middleware would be something like:
Recently, I tried to write a WAI Middleware that was aware of the API my application was using. In particular, given an incoming request url, I wanted to be able to tell which endpoint was used, and which parts of the url were captured.
For instance, consider the server api below:
Let us request it with the following command:
If the request succeeds, we should get a Foo object, encoded as JSON.
The additional data I would like to get from Servant for my middleware would be something like:
The
"content-type"
part is easy to get from the response header, but the"url"
part doesn't seem easily available.Effectively, what I would need is a way to perform the transformation
GET "/foo/12345"
=>GET "/foo/<id::Int>"
I can think of several ways for Servant to provide this information:
then the response headers would include
"Effective-Url": "/foo/<id::Int>"
Servant.Middleware
that would be aware of API resolution mechanisms.The text was updated successfully, but these errors were encountered: