Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors redirect handling to remove the generic redirect policy trait and instead route redirect decisions through a single internal FollowRedirectPolicy, simplifying the redirect middleware’s type surface.
Changes:
- Replace the generic redirect
Policytrait with concreteFollowRedirectPolicymethods (redirect,for_request,on_request,on_response). - Simplify public redirect
Actioninto a tuple wrapper and adjust pending-action wiring to map into internalredirect::Action. - Narrow redirect middleware to operate on the crate
Bodytype (instead of generic request bodies).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/redirect.rs | Refactors redirect Action wrapper and pending action mapping; moves redirect policy logic into FollowRedirectPolicy methods. |
| src/client/layer/redirect/policy.rs | Removes the generic Policy trait, leaving only redirect attempt/action types for the middleware. |
| src/client/layer/redirect/future.rs | Updates redirect future to use FollowRedirectPolicy directly and simplifies body cloning mechanics. |
| src/client/layer/redirect.rs | Refactors redirect layer/service to use FollowRedirectPolicy directly and only operate on crate Body. |
| src/client.rs | Updates the client service stack type alias to match the new redirect middleware type signature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
3
to
+5
| use std::{fmt, pin::Pin}; | ||
|
|
||
| use http::{HeaderMap, Request, Response, StatusCode, Uri}; | ||
| use http::{HeaderMap, StatusCode, Uri}; |
Comment on lines
253
to
258
| Poll::Pending | ||
| } | ||
| Action::Stop => Poll::Ready(Ok(redirect.res)), | ||
| Action::Pending(_) => Poll::Ready(Err(S::Error::from( | ||
| Error::redirect( | ||
| "Nested pending Action is not supported in redirect policy", | ||
| redirect.parts.uri.clone(), | ||
| ) | ||
| .into(), | ||
| ))), | ||
| Action::Error(err) => Poll::Ready(Err(err.into())), | ||
| Action::Pending(_) => unreachable!(), | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.