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.
Hi, the root of this PR is to change:
to
Here,
a
is the value returned by the handler, so this is supposed to run after a successful route match. However, theMaybe
indicates whether theAcceptHeader
is one that we are accepting specified by theProxy list
.This is a problem because we want to know if the
AcceptHeader
contains a valid value before we run the handler on it and extract thea
. In the original version of the function, we need to run the handler first, and only then we find out if the request contains an appropriate header.The consequences of this is that we sort force the user to do an additional separate check and then some form of an unsafe coercions/ awkard error throw in order to bypass the
Maybe
.Example of awkward error throw:
servant/servant-server/src/Servant/Server/Internal.hs
Line 326 in 7ae7873
If it seems like a good idea to introduce this API change. I'm happy to update the rest of the projects in this repo.
Cheers.