Http DSL: produce specific rejections from PathMatchers that unmarshal a type
- Dominant language
- Scala
- Stars
- 1.4k
- Forks
- 584
- Avg merge
- 14h 33m
- Merged PRs (30d)
- 24
Description
**Issue by [agemooij](https://github.com/agemooij)**
_Friday Oct 16, 2015 at 17:25 GMT_
_Originally opened as https://github.com/akka/akka/issues/18733_
---
There was this question on the `spray/spray` Gitter channel:
> I there any way to create path("guid" / JavaUUID) { } which would match UUID and if it is not properly formatted UUID, it would reject request with Bad Request?
The `rawPathPrefix` directive [always rejects with an empty rejection list](https://github.com/akka/akka/blob/releasing-akka-stream-and-http-experimental-1.0/akka-http/src/main/scala/akka/http/scaladsl/server/directives/PathDirectives.scala#L37) while it might be very useful for users to provide some kind of unmarshalling rejection when a `PathMatcher` fails during conversion. This allows the user to handle those rejections at the level that they need, either by wrapping with the `handleRejections` directive or by letting the rejection bubble up to the default handler.
Of course this might interfere with the current way that 404/NotFound is currently handled so those rejections might have to be cancelled at some level? Might be a tricky one to achieve without deep changes.
Contributor guide
Research direction
Start with rawPathPrefix in akka-http/src/main/scala/akka/http/scaladsl/server/directives/PathDirectives.scala, especially its current empty rejection behavior. Trace how PathMatcher conversion failures reach rejection handling and the default 404/NotFound response. Done means conversion failures expose usable unmarshalling rejections without breaking existing not-found handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100