-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Servant MultiVerb #1649
Servant MultiVerb #1649
Conversation
bc78f9e
to
2f57302
Compare
Also convert conversation creation endpoints to use MultiVerb as a test case for headers.
By the time we find a content type mismatch, the handler has already run, so we should fail with FailFatal to avoid trying another handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! I left a few minor comments.
It should use the underlying monoid instance of `UndenderResult Void`. Thanks @mdimjasevic for spotting this.
7f74b8a
to
d2fa599
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks very neat ✨
I have posted a few questions in comments.
data UnrenderResult a = Mismatch | UnrenderError String | UnrenderSuccess a | ||
deriving (Eq, Show, Functor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does Mismatch
mean?
type ResponseStatus (Respond s desc a) = s | ||
|
||
responseRender (AcceptHeader acc) x = | ||
M.mapAcceptMedia (map (uncurry mkRenderOutput) (allMimeRender (Proxy @cs) x)) acc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we don't use it, but for my education, would this make the server render output for all media types that the server supports and then choose which one to respond with? If so, we may want to rewrite this using M.matchAccept
and then rendering?
fromHeaders = id | ||
toHeaders = id | ||
|
||
data DescHeader (name :: Symbol) (desc :: Symbol) (a :: *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be better to see if we could support having Servant.Description
in the mods
variable of Servant.Header'
. Did you already try that? Might save us some code here and may even be easily upstream-able into servant-swagger.
This introduces a new
Verb
-like type for Servant endpoints:MultiVerb
. TheMultiVerb
type can be used as an alternative toUVerb
, and it provides approximately the same functionality as the latter, with a few differences:MultiVerb
can subsumeVerb
.This PR only adds the
MultiVerb
type and uses it for the two user HEAD endpoints (qualified and unqualified). The followup PR #1657 appliesMultiVerb
to a few other endpoints and makesErrorDescription
types work asMultiVerb
responses.Checklist