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)

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]>

impl<T: http_body::Body> IntoResponse for (http::StatusCode, T) {
fn into_response(self) -> HttpResult<types::Response> {
unreachable!()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentional? Using unreachable! rather than todo!() makes me assume so but maybe add a comment on why it is unreachable?

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 this one slipped by! Ill fix, thanks for calling it out!

/// The macro expands into a module containing a `Spin` struct that implements the
/// WASI `http.handler/Guest` interface, wiring the annotated function as the
/// handler’s entrypoint. This allows the function to be invoked automatically
/// by the Spin runtime when HTTP requests are received.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: we should have an # Example section showing this macro in use.

Error::Other(e) => write!(f, "{e}"),
Error::Response(e) => match http::StatusCode::from_u16(e.get_status_code()) {
Ok(status) => write!(f, "{status}"),
Err(e) => write!(f, "{e}"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure "{e}" will show a good error message. Perhaps we hardcode it to "invalid status code"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps even "invalid status code {}", e.get_status_code()? (With e not shadowed in the match arm, obvs)

Copy link
Contributor

Choose a reason for hiding this comment

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

This code is already in the process of being upstreamed: bytecodealliance/wasi-rs#126

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.

5 participants