finagle / finagle/finch

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

Open
#983 6 comments 0 reactions 0 assignees View on GitHub
enhancement
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.