- 
                Notifications
    
You must be signed in to change notification settings  - Fork 17
 
Add support for WASI P3 #87
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
Changes from 1 commit
4142f96
              ddd7b29
              af614bf
              bc2ba7a
              c230ba0
              0aa0165
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -17,22 +17,24 @@ The Spin Rust SDK makes it easy to build Spin components in Rust. | |
| name = "spin_sdk" | ||
| 
     | 
||
| [dependencies] | ||
| anyhow = "1" | ||
| anyhow = { workspace = true } | ||
| async-trait = "0.1.74" | ||
| chrono = "0.4.38" | ||
| form_urlencoded = "1.0" | ||
| postgres_range = { version = "0.11.1", optional = true } | ||
| rust_decimal = { version = "1.37.2", default-features = false, optional = true } | ||
| spin-executor = { version = "5.0.0", path = "crates/executor" } | ||
| spin-macro = { version = "5.0.0", path = "crates/macro" } | ||
| thiserror = "1.0.37" | ||
| spin-wasip3-http = { version = "5.0.0", path = "crates/spin-wasip3-http" } | ||
| spin-wasip3-http-macro = { version = "5.0.0", path = "crates/spin-wasip3-http-macro" } | ||
| thiserror = { workspace = true } | ||
| uuid = { version = "1.18.0", optional = true } | ||
| wit-bindgen = { workspace = true } | ||
| routefinder = "0.5.3" | ||
| once_cell = { workspace = true } | ||
| futures = { workspace = true } | ||
| bytes = "1" | ||
| hyperium = { package = "http", version = "1.0.0" } | ||
| bytes = { workspace = true } | ||
| hyperium = { workspace = true } | ||
| serde_json = { version = "1.0.96", optional = true } | ||
| serde = { version = "1.0.163", optional = true } | ||
| wasi = { workspace = true } | ||
| 
          
            
          
           | 
    @@ -65,6 +67,9 @@ members = [ | |
| "examples/variables", | ||
| "examples/wasi-http-streaming-outgoing-body", | ||
| "examples/wasi-http-streaming-file", | ||
| "examples/wasip3-http-axum-router", | ||
| "examples/wasip3-http-hello-world", | ||
| "examples/wasip3-http-send-request", | ||
| "test-cases/simple-http", | ||
| "test-cases/simple-redis", | ||
| "crates/*", | ||
| 
          
            
          
           | 
    @@ -92,12 +97,19 @@ authors = ["Spin Framework Maintainers <[email protected]>"] | |
| edition = "2021" | ||
| license = "Apache-2.0 WITH LLVM-exception" | ||
| repository = "https://github.com/spinframework/spin-rust-sdk" | ||
| rust-version = "1.78" | ||
| rust-version = "1.86" | ||
| homepage = "https://spinframework.dev/rust-components" | ||
| 
     | 
||
| [workspace.dependencies] | ||
| anyhow = "1" | ||
| hyperium = { package = "http", version = "1.3.1" } | ||
| http-body = "1.0.1" | ||
| http-body-util = "0.1.3" | ||
| bytes = "1.10.1" | ||
| wit-bindgen = "0.43.0" | ||
| futures = "0.3.28" | ||
| once_cell = "1.18.0" | ||
| thiserror = "2.0.17" | ||
| # Pin to the last version that targeted WASI 0.2.0 | ||
| wasi = "=0.13.1" | ||
| wasip3 = "0.2.0" | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [package] | ||
| name = "spin-wasip3-http-macro" | ||
| version.workspace = true | ||
| authors.workspace = true | ||
| edition.workspace = true | ||
| license.workspace = true | ||
| repository.workspace = true | ||
| rust-version.workspace = true | ||
| homepage.workspace = true | ||
| description = """ | ||
| Rust procedural macros for Spin and associated WIT files | ||
| """ | ||
| 
     | 
||
| [lib] | ||
| name = "spin_wasip3_http_macro" | ||
| proc-macro = true | ||
| 
     | 
||
| [dependencies] | ||
| proc-macro2 = "1" | ||
| quote = "1.0" | ||
| syn = { version = "1.0", features = [ "full" ]} | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| use proc_macro::TokenStream; | ||
| use quote::quote; | ||
| 
     | 
||
| /// TODO | ||
| #[proc_macro_attribute] | ||
| pub fn http_component(_attr: TokenStream, item: TokenStream) -> TokenStream { | ||
                
       | 
||
| let func = syn::parse_macro_input!(item as syn::ItemFn); | ||
| 
     | 
||
| if func.sig.asyncness.is_none() { | ||
| return syn::Error::new_spanned( | ||
| func.sig.fn_token, | ||
| "the `#[http_component]` function must be `async`", | ||
| ) | ||
| .to_compile_error() | ||
| .into(); | ||
| } | ||
| 
     | 
||
| let func_name = &func.sig.ident; | ||
| 
     | 
||
| quote!( | ||
| #func | ||
| mod __spin_wasip3_http { | ||
| use ::spin_sdk::http_wasip3::IntoResponse; | ||
| 
     | 
||
| struct Spin; | ||
| ::spin_sdk::http_wasip3::wasip3::http::proxy::export!(Spin); | ||
| 
     | 
||
| impl ::spin_sdk::http_wasip3::wasip3::exports::http::handler::Guest for self::Spin { | ||
| async fn handle(request: ::spin_sdk::http_wasip3::wasip3::http::types::Request) -> Result<::spin_sdk::http_wasip3::wasip3::http::types::Response, ::spin_sdk::http_wasip3::wasip3::http::types::ErrorCode> { | ||
| let request = <::spin_sdk::http_wasip3::IncomingRequest as ::spin_sdk::http_wasip3::FromRequest>::from_request(request)?; | ||
| ::spin_sdk::http_wasip3::IntoResponse::into_response(super::#func_name(request).await) | ||
| } | ||
| } | ||
| } | ||
| ) | ||
| .into() | ||
| } | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| [package] | ||
| name = "spin-wasip3-http" | ||
| version.workspace = true | ||
| authors.workspace = true | ||
| edition.workspace = true | ||
| license.workspace = true | ||
| repository.workspace = true | ||
| rust-version.workspace = true | ||
| homepage.workspace = true | ||
| 
     | 
||
| [dependencies] | ||
| anyhow = { workspace = true } | ||
| bytes = { workspace = true } | ||
| http-body = { workspace = true } | ||
| http-body-util = { workspace = true } | ||
| hyperium = { workspace = true } | ||
| wasip3-http-ext = { version = "5.0.0", path = "../wasip3-http-ext" } | ||
| wasip3 = { workspace = true } | 
Uh oh!
There was an error while loading. Please reload this page.