Skip to content

refactor(redirect): simplify internal abstractions for redirect handling#1200

Open
0x676e67 wants to merge 1 commit into
mainfrom
redirect
Open

refactor(redirect): simplify internal abstractions for redirect handling#1200
0x676e67 wants to merge 1 commit into
mainfrom
redirect

Conversation

@0x676e67

Copy link
Copy Markdown
Owner

No description provided.

gemini-code-assist[bot]

This comment was marked as spam.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Policy trait with concrete FollowRedirectPolicy methods (redirect, for_request, on_request, on_response).
  • Simplify public redirect Action into a tuple wrapper and adjust pending-action wiring to map into internal redirect::Action.
  • Narrow redirect middleware to operate on the crate Body type (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!(),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants