Only Handlers with Request input can have HandlerAspects applied (#2527) #2600
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fix gives
Handler#@@
the meaning it was supposed to have. It should only work on handlers whereIn =:= Request
.But that was not true. Because of the way the check was implemented, scala could infer
Nothing
for theIn1
and it would compile. Leading then to the runtime error one can see in #2527.The more interesting question is: Can we define a generic
HandlerAspect.identity
and a generic version ofHandler#@@
that not only accepts thisidentity
but also other similar aspects?After some playing around, I think the answer is probably no.
The two versions of
@@
that exist, both return aHandler
that has aIn =:= Request
. But in my opinion, a trueHandlerAspect.identity
, that is not only defined for aHandler
that has aIn =:= Request
, must preserve theIn
type.No
applyX
version ofHandlerAspect
can do this currently. The one that would be a candidate to be changed in that way would beapplyHandler
.So I tried
But because
protocol.incomingHandler
requiresRequest
, I endup with a result type ofHandler[Env1, Response, In with Request, Response]
instead ofHandler[Env1, Response, In, Response]
.@jdegoes @vigoo If you see a way how to solve this, please let me know and I'll adjust the PR.
fixes #2527
/claim #2527