Skip to content
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

Rework middleware to receive Response directly, add optional errors to Response #570

Merged
merged 5 commits into from
Jul 9, 2020

Commits on Jul 7, 2020

  1. Response: add optional error storage

    This allows errors to be propagated through the Tide middleware stack
    while still keeping an existing Response intact. Effectively allowing
    headers, body, etc to be passed along with an Error; while also opening
    up options for nicer error handling via `res.downcast_error<>` checking.
    
    Also contains APIs for turning an Error into a Response via Into, and
    taking the error from / setting an error on an existing Response.
    
    This is a breaking change in that `next.run().await` within middleware
    no longer returns a tide::Result but rather always returns a
    tide::Response.
    
    Thanks to Jacob Rothstein for helping me get this to compile!
    
    PR-URL: http-rs#570
    Fishrock123 committed Jul 7, 2020
    Configuration menu
    Copy the full SHA
    506352a View commit details
    Browse the repository at this point in the history
  2. Examples: add error handling example

    Makes use of the newly introduced error propgation from
    `Response: add optional error storage` to show a nice and
    flexible error handler middleware approach.
    
    Related to http-rs#549
    Fishrock123 committed Jul 7, 2020
    Configuration menu
    Copy the full SHA
    fd279e1 View commit details
    Browse the repository at this point in the history
  3. LogMiddleware: do something with res.error()

    Makes use of the newly updated error propgation from
    `Response: add optional error storage` for a more
    informative error case in the log middleware.
    Fishrock123 committed Jul 7, 2020
    Configuration menu
    Copy the full SHA
    77ddda2 View commit details
    Browse the repository at this point in the history
  4. Server: remove default body behavior for errors

    This is probably never what a Tide user wants.
    
    The developer of a server can use the log middleware, otherwise this presents a risk as it may point to potentially exploitable flaws.
    
    Additionally, Tide can't completely aguarentee this will be in an expected format.
    Fishrock123 committed Jul 7, 2020
    Configuration menu
    Copy the full SHA
    f4ef3bb View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    2c59a63 View commit details
    Browse the repository at this point in the history