11//! The Rust Spin SDK.
22
33#![ deny( missing_docs) ]
4+ #![ cfg_attr( docsrs, feature( doc_cfg) ) ]
45
56#[ cfg( test) ]
67mod test;
@@ -19,14 +20,56 @@ pub mod llm;
1920
2021pub use spin_macro:: * ;
2122
22- /// WASIp3 HTTP APIs and helpers
23+ /// WASIp3 HTTP APIs and helpers.
24+ ///
25+ /// **The contents of this module are unstable.** Module APIs may change in future releases,
26+ /// and may not work with future versions of Spin (as they bind to a particular WASI RC
27+ /// which Spin will retire once a stable WASIp3 is available)/
2328#[ cfg( feature = "wasip3-unstable" ) ]
29+ #[ cfg_attr( docsrs, doc( cfg( feature = "wasip3-unstable" ) ) ) ]
2430pub mod http_wasip3 {
25- /// Re-exports the helpers types for converting between WASIp3 HTTP types and
26- /// Rust ecosystem HTTP types.
2731 pub use spin_wasip3_http:: * ;
28- /// Re-exports the macro to enable WASIp3 HTTP handlers
29- pub use spin_wasip3_http_macro:: * ;
32+
33+ /// Marks an `async fn` as an HTTP component entrypoint for Spin.
34+ ///
35+ /// The `#[http_service]` attribute designates an asynchronous function as the
36+ /// handler for incoming HTTP requests in a Spin component using the WASI Preview 3
37+ /// (`wasip3`) HTTP ABI.
38+ ///
39+ /// When applied, this macro generates the necessary boilerplate to export the
40+ /// function to the Spin runtime as a valid HTTP handler. The function must be
41+ /// declared `async` and take a single argument implementing
42+ /// [`FromRequest`], typically
43+ /// [`Request`], and must return a type that
44+ /// implements [`IntoResponse`].
45+ ///
46+ /// # Requirements
47+ ///
48+ /// - The annotated function **must** be `async`.
49+ /// - The function’s parameter type must implement [`FromRequest`].
50+ /// - The return type must implement [`IntoResponse`].
51+ /// - The Spin manifest must specify `executor = { type = "wasip3-unstable" }`
52+ ///
53+ /// If the function is not asynchronous, the macro emits a compile-time error.
54+ ///
55+ /// # Example
56+ ///
57+ /// ```ignore
58+ /// use spin_sdk::http_wasip3::{http_service, Request, IntoResponse};
59+ ///
60+ /// #[http_service]
61+ /// async fn my_handler(request: Request) -> impl IntoResponse {
62+ /// // Your logic goes here
63+ /// }
64+ /// ```
65+ ///
66+ /// # Generated Code
67+ ///
68+ /// The macro expands into a module containing a `Spin` struct that implements the
69+ /// WASI `http.handler/Guest` interface, wiring the annotated function as the
70+ /// handler’s entrypoint. This allows the function to be invoked automatically
71+ /// by the Spin runtime when HTTP requests are received.
72+ pub use spin_wasip3_http_macro:: http_service;
3073}
3174
3275#[ doc( hidden) ]
0 commit comments