Endpoint.collectX
- Dominant language
- Scala
- Stars
- 1.6k
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
As discussed [on Gitter](https://gitter.im/finagle/finch?at=57e9840f35e0f31c6c4542ac) it would be quite useful to define `Endpoint.collectX` alternatives that determine whether or not this endpoint matches. This may help us to replace our `headerExists` and `paramExists` endpoints with something like `header("foo").collect { case Some(s) => s }`.
Right now I'm thinking about:
``` scala
def collect[B](pf: PartialFunction[A, B]): Endpoint[B]
def collectOutput[B](pf: PartialFunction[A, Output[B]]): Endpoint[B]
def collectAsync[pf: PartialFunction[A, Future[B]]]): Endpoint[B]
def collectOutputAsync[pf: PartialFunction[A, Future[Output[B]]]]): Endpoint[B]
```
Contributor guide
Research direction
Start by reading the existing Endpoint combinators and the headerExists and paramExists endpoints referenced in the issue. Compare their matching and asynchronous behavior with the four proposed collect variants, then determine the intended API and validation needed before implementing it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100