-
Notifications
You must be signed in to change notification settings - Fork 263
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
Support interceptor in spin outbound http #2817
Conversation
use spin_world::async_trait; | ||
use wasmtime_wasi_http::{body::HyperOutgoingBody, HttpResult}; | ||
|
||
pub type HyperBody = HyperOutgoingBody; |
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.
This seems a bit unnecessary? I don't see how HyperBody
is clearer than HyperOutgoingBody
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.
It's used in the Complete
variant below, where it is actually an incoming body. I don't really know why wasmtime_wasi_http
has both types; they alias the same underlying type...
pub trait OutboundHttpInterceptor: Send + Sync { | ||
/// Intercept an outgoing HTTP request. | ||
/// | ||
/// If this method returns [`InterceptedResponse::Continue`], the (possibly |
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.
I think the docs here are slightly wrong since we're no longer updating requests but rather passing the request and back out.
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.
You can still update it, just as owned-mut
rather than &mut
. 🤷
} | ||
|
||
impl InterceptRequest { | ||
pub fn into_hyper_request(self) -> Request<HyperBody> { |
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.
Can this also be pub(crate)
?
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.
External impls need it to get the request body in the InterceptOutcome::Complete
path.
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
987cb41
to
24ab63b
Compare
InterceptRequest
wrapper type to handle differences between spin and wasi requestsintercept
request param owned to be returned inInterceptOutcome::Continue
branch, replacing awkwardstd::mem::take