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
feat(ext/fetch): support fallible request-builder hooks #18116
Conversation
This tweaks the signature of `request_builder_hook` in order to support fallible hooks. The rationale for this is mostly on two sides: * it allows a hook to inspect and possibly drop an outgoing request (e.g. for policying purposes), bubbling up a detailed error message to the user. * it wires into newer `reqwest` API which allows to split and then reassemble a `RequestBuilder`, although only in a fallible way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description of the PR says it uses the new RequestBuilder::from_parts() but I don't see it in the code. I am probably misunderstanding the intent of the second point?
@satyarohith fn custom_hook(input: RequestBuilder) -> Result<RequestBuilder, AnyError> {
let (client, inner_req) = input.build_split();
let req = inner_req?;
// ... Manipulate `req` as needed here ...
let output = RequestBuilder::from_parts(client, req);
Ok(output)
} |
Understood. Thanks for the explanation! |
This tweaks the signature of `request_builder_hook` in order to support fallible hooks. The rationale for this is mostly on two sides: * it allows a hook to inspect and possibly drop an outgoing request (e.g. for policying purposes), bubbling up a detailed error message to the user. * it wires into newer `reqwest` API which allows to split and then reassemble a `RequestBuilder`, although only in a fallible way (seanmonstar/reqwest#1770)
This tweaks the signature of
request_builder_hook
in order to support fallible hooks.The rationale for this is mostly on two sides:
reqwest
API which allows to split and then reassemble aRequestBuilder
, although only in a fallible way (async/request: add methods to split and reassemble a RequestBuilder seanmonstar/reqwest#1770)