Header-Endpoint that only matches specific values, akin to path
- Dominant language
- Scala
- Stars
- 1.6k
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
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
```
Contributor guide
Research direction
The issue names no files or tests; start by locating the existing path matching endpoint and the header-endpoint entry point. Done means a header endpoint factory matches only when the named header is present with the requested value, supporting the shown v1/v2 endpoint composition, with coverage in the relevant endpoint tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100