-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New redirect inspection #3377
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
base: main
Are you sure you want to change the base?
New redirect inspection #3377
Conversation
Could also .expect the |
(suggested in the issue above) We could introduce a RedirectKind which means we don't have to assert the StatusCode, and also turn that into the valid status code when using IntoResponse meaning we can eliminate any code that may in any way panic. And also we are going towards 0.9, and since breaking changes were allowed, it's a better time to do it before 0.9 |
I think we should just update the location field to be a |
Motivation
This PR was made in response to the issue #3365.
Highlights that in axum most responses are strongly typed (and therefore inspectable) and is turned into HTTP at the IntoResponse stage.
Redirect does not have any methods to inspect StatusCode or the URI after being constructed, and constructs the http headers when created.
Solution
This PR adds testability and inspection of
Redirect
.It adds
status_code()
which returns the current status code of the Redirect, andlocation()
which returns the result of parsing the Http Header to a &str.It also adds tests using the new inspection methods.
This PR should also be iterated on, but currently doesn't have any breaking changes to the internals of Redirect, but only adds new methods. We could still make these changes (discussed in the issue above):
IntoResponse
.