question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Header-Endpoint that only matches specific values, akin to path

See original GitHub issue

It 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:open
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
vkostyukovcommented, Sep 18, 2018

Perhaps headerExact("foo", "bar") could be a reasonable API to expose (that’s what warp uses)?

0reactions
d-s-dcommented, Dec 8, 2018

@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, or headerDispatch. Or did I misunderstand your remark?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found