-
Notifications
You must be signed in to change notification settings - Fork 157
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
Refactor Response API and trim NickelError #170
Conversation
… harder The majority of the Response api now returns a MiddlewareResult. [breaking-change]
Additionally rename `status_code` to `set_status` and introduce `status` to access the current status code for a `Response`. [breaking-change]
Nice! Does @cburgdorf or @rgs1 have an opinion on this and #168? |
Taking a look now |
Nice work @Ryman :-) Left some comments/nits with each commit - will do a 2nd pass tomorrow. |
Currently blocked on hyper, will push up edits once I know they compile! |
Last commit has some rust/hyper changes and addresses @rgs1's feedback. |
Sweet - thanks @Ryman. Will look at it in a bit. |
generally lgtm, i'd merge and we can keep iterating from there |
@simonpersson good to merge? |
Yes, go ahead and merge :) |
Refactor Response API and trim NickelError
Alternative to #168.
Providing a separate PR incase the design isn't agreeable (this is based on that branch).
These changes make it easier to enforce standard behavior. HTTP doesn't really allow changing the status code once a response is already in progress, so users should either bail (and log) or start an error with an appropriate code which error handlers can process.
I considered changing the API for an ErrorHandler to take
&mut Option<Response<Streaming>>
but decided to keepNickelError
as in the absense of aResponse
we can at least still know what the developers error message was (in case they want to log something to a database rather than nothing).