Skip to content

Conversation

@fibonacci1729
Copy link
Contributor

@fibonacci1729 fibonacci1729 commented Oct 15, 2025

Moves the contents of the prototype repo into the sdk.

The additions are factored into 3 new crates:

  • spin-wasip3-http-macro
  • spin-wasip3-http
  • wasip3-http-ext (to be upstreamed) UPSTREAMED

The contents of these repo are accessible via the spin_sdk through the http_wasip3 module.

Draft for now while I make a final pass to eliminate low hanging TODOs. Nevertheless requesting reviews now.

@fibonacci1729
Copy link
Contributor Author

cc/ @alexcrichton @tschneidereit for comments on the general shape of the upstreamable bits and possible next steps on where this could live.

Signed-off-by: Brian Hardock <[email protected]>
Copy link
Contributor

@itowlson itowlson left a comment

Choose a reason for hiding this comment

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

I don't feel able to comment on the implementation, although what I saw looked very cool - the same kind of "wow this is going to be super convenient" as some of Ryan's early work on the Spin HTTP SDK.

I had some surface level nits and suggestions but in terms of the overall stuff it looks great to me but definitely needs other eyes on it.

@lann
Copy link
Contributor

lann commented Oct 16, 2025

Do we want to more-explicitly frame this initial implementation as experimental/unstable (feature flag, unstable in the module name, ...)? I wouldn't necessarily want to commit to this specific RC, especially given a certain pending change. 🙂

@fibonacci1729
Copy link
Contributor Author

This commit eliminates the http_body_util dependency in the wasip3_http_ext crate .

@fibonacci1729 fibonacci1729 force-pushed the wasip3 branch 2 times, most recently from f064bcc to 3dc8d5b Compare October 16, 2025 20:41
@fibonacci1729 fibonacci1729 marked this pull request as ready for review October 16, 2025 20:44
@fibonacci1729 fibonacci1729 force-pushed the wasip3 branch 2 times, most recently from 4e09979 to 0c104dc Compare October 16, 2025 21:47
@fibonacci1729
Copy link
Contributor Author

fibonacci1729 commented Oct 16, 2025

Once bytecodealliance/wasi-rs#126 lands I'll remove the wasip3-http-ext crate here.

Signed-off-by: Brian Hardock <[email protected]>
/// handler’s entrypoint. This allows the function to be invoked automatically
/// by the Spin runtime when HTTP requests are received.
#[proc_macro_attribute]
pub fn http_component(_attr: TokenStream, item: TokenStream) -> TokenStream {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is http_component the right name? http_handler?

Copy link
Contributor Author

@fibonacci1729 fibonacci1729 Oct 23, 2025

Choose a reason for hiding this comment

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

As the person who introduced http_component way back in the day, I've never loved it. Im not opposed to making this switch but I do have FUD around deviating from the norm and consistency with other sdk exports (e.g. redis, cron, mqtt, etc.).

I'd be curious to hear @itowlson's thoughts here from a dx/docs perspective.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@lann lann Oct 23, 2025

Choose a reason for hiding this comment

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

...and would also lead the way toward a #[http_middleware] macro. 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah. That would be my vote.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we switch to service or handler or whatever, I'd consider retaining component (even in P3) as a transitional thing - prevalence in existing docs/blog posts, other trigger types, etc. And I am wary of rushing this decision in the last few days/hours before 3.5. But yeah I love http_component about as much as Brian does.

I'm not sure why middleware needs a different signature with a MiddlewareThingWrappingImportHandler. Why would the component not just call the global next() (or handle() or however the SDK surfaces the import) function in the way we normally do for host functions? To me it feels awkward for this one thing, one amongst all our other globals, to be injected. Or is your ... in the signature meant to imply that other things will be injected too? Anyway not an issue for now.

Copy link
Contributor

@lann lann Oct 23, 2025

Choose a reason for hiding this comment

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

I'm not sure why middleware needs a different signature with a MiddlewareThingWrappingImportHandler.

It doesn't, but my (piping hot) take is that we should pretend like it does because otherwise middleware signatures will look exactly like plain old service signatures and that seems more confusing.

Copy link
Contributor

@lann lann Oct 23, 2025

Choose a reason for hiding this comment

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

Actually we'd probably really like to not even generate the bindings for this handler import outside of #[http_middleware]. A "fake" argument seems to me like it could be the least-bad way to present that.

Copy link
Contributor Author

@fibonacci1729 fibonacci1729 Oct 23, 2025

Choose a reason for hiding this comment

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

I think we should let this simmer until tomorrow to let EU folks pipe up so i'll plan to merge this PR tomorrow afternoon.

My vote would be to rename to #[http_service] because this entrypoint feels more analogous to a tower_service::Service than to what Axum refers to as a "handler". BUT whatever the people want.

I suppose to @itowlson's transitioning point, I could add:

pub use spin_wasip3_http_macro::{
        http_service, 
        http_service as http_component,
};

... to where we export all the things in lib.rs

Copy link
Contributor Author

@fibonacci1729 fibonacci1729 Oct 24, 2025

Choose a reason for hiding this comment

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

I'm going to go ahead and make the change to #[http_service]. However, this PR will remain open until Monday to leave an opportunity to object!

Copy link
Contributor

@itowlson itowlson left a comment

Choose a reason for hiding this comment

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

LGTM. I imagine we're going to need some iteration as we gain more experience with it so I like putting it under a feature guard while we and others kick the tyres on it!

@fibonacci1729 fibonacci1729 force-pushed the wasip3 branch 2 times, most recently from a7e4545 to 38e9cd6 Compare October 23, 2025 20:38
@fibonacci1729 fibonacci1729 force-pushed the wasip3 branch 2 times, most recently from 5029f03 to 610d5d9 Compare October 23, 2025 21:27
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.

6 participants