Header-Endpoint that only matches specific values, akin to path
See original GitHub issueIt would be convenient to have a header-endpoint that matches iff a header is present with a particular value. This is useful in situations where one wants to provide different business logic depending on that value. An example of this is API-Versioning: Let’s assume that such an endpoint-factory would exist and header(x, y)
matched iff header x
was present with value y
. Then one could solve this problem as follows:
val v1Endpoint: Endpoint[ResponseV1] =
get("myEndpoint" :: header("X-API-VERSION", "1")) { /* ... */ }
val v2Endpoint: Endpoint[ResponseV2] =
get("myEndpoint" :: header("X-API-VERSION", "2")) { /* ... */ }
val allVersions = v1Endpoint :+: v2Endpoint
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
HTTP header manipulation - Envoy Proxy
The :path header is a pseudo-header populated by Envoy using the value of the path of the HTTP ... The header is only...
Read more >Content-Security-Policy - HTTP - MDN Web Docs
Chrome Edge
Content‑Security‑Policy Full support. Chrome25. more. Toggle history Full sup...
base‑uri Full support. Chrome40. Toggle history Full sup...
block‑all‑mixed‑content. Deprecated Full support. ChromeYes. Toggle history...
Read more >How to Build a POST Request with Replacement Variables for ...
This article describes how to send data via HTTP POST along with dynamic "Replacement Variable" values configured in the operation.
Read more >Values that you specify when you create or update a distribution
When you use the CloudFront console to create a new distribution or update an existing distribution, you specify the following values.
Read more >Minimal APIs quick reference - Microsoft Learn
The first group of endpoints will only match requests prefixed with /public/todos and are accessible without any authentication.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Perhaps
headerExact("foo", "bar")
could be a reasonable API to expose (that’s what warp uses)?@sergeykolbasov That is the point, I think. Similar to the path, this endpoint can be used to dispatch a request. Maybe a different name would do:
headerMatch
, orheaderDispatch
. Or did I misunderstand your remark?