Skip to content

Commit 0aa0165

Browse files
committed
Rename http_component to http_service and use unstable executor
Signed-off-by: Brian Hardock <[email protected]>
1 parent c230ba0 commit 0aa0165

File tree

9 files changed

+17
-13
lines changed

9 files changed

+17
-13
lines changed

crates/spin-wasip3-http-macro/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use quote::quote;
33

44
/// Marks an `async fn` as an HTTP component entrypoint for Spin.
55
///
6-
/// The `#[http_component]` attribute designates an asynchronous function as the
6+
/// The `#[http_service]` attribute designates an asynchronous function as the
77
/// handler for incoming HTTP requests in a Spin component using the WASI Preview 3
88
/// (`wasip3`) HTTP ABI.
99
///
@@ -25,9 +25,9 @@ use quote::quote;
2525
/// # Example
2626
///
2727
/// ```ignore
28-
/// use spin_sdk::http_wasip3::{http_component, Request, IntoResponse};
28+
/// use spin_sdk::http_wasip3::{http_service, Request, IntoResponse};
2929
///
30-
/// #[http_component]
30+
/// #[http_service]
3131
/// async fn my_handler(request: Request) -> impl IntoResponse {
3232
/// // Your logic goes here
3333
/// }
@@ -40,7 +40,7 @@ use quote::quote;
4040
/// handler’s entrypoint. This allows the function to be invoked automatically
4141
/// by the Spin runtime when HTTP requests are received.
4242
#[proc_macro_attribute]
43-
pub fn http_component(_attr: TokenStream, item: TokenStream) -> TokenStream {
43+
pub fn http_service(_attr: TokenStream, item: TokenStream) -> TokenStream {
4444
let func = syn::parse_macro_input!(item as syn::ItemFn);
4545

4646
if func.sig.asyncness.is_none() {

examples/wasip3-concurrent-outbound-http-calls/spin.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ description = "Demonstrates making concurrent outbound HTTP calls in WASIp3"
1111
[[trigger.http]]
1212
route = "/..."
1313
component = "concurrent-outbound-http-calls"
14+
executor = { type = "wasip3-unstable" }
1415

1516
[component.concurrent-outbound-http-calls]
1617
source = "target/wasm32-wasip2/release/concurrent_outbound_http_calls.wasm"

examples/wasip3-concurrent-outbound-http-calls/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use std::pin::pin;
33
use futures::future::Either;
44
use http::Request;
55
use spin_sdk::http_wasip3::{send, EmptyBody, IntoResponse};
6-
use spin_sdk::http_wasip3::http_component;
6+
use spin_sdk::http_wasip3::http_service;
77

8-
#[http_component]
8+
#[http_service]
99
async fn handle_concurrent_outbound_http_calls(_req: spin_sdk::http_wasip3::Request) -> anyhow::Result<impl IntoResponse> {
1010

1111
let spin = pin!(get_content_length("https://spinframework.dev"));

examples/wasip3-http-axum-router/spin.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ description = "An example application using axum"
1111
[[trigger.http]]
1212
route = "/..."
1313
component = "axum-router"
14+
executor = { type = "wasip3-unstable" }
1415

1516
[component.axum-router]
1617
source = "../../target/wasm32-wasip2/release/axum_router.wasm"

examples/wasip3-http-axum-router/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ use axum::{
44
Json, Router,
55
};
66
use serde::{Deserialize, Serialize};
7-
use spin_sdk::http_wasip3::{http_component, IntoResponse, Request};
7+
use spin_sdk::http_wasip3::{http_service, IntoResponse, Request};
88
use tower_service::Service;
99

10-
/// Sends a request to a URL.
11-
#[http_component]
10+
/// Demonstrates integration with the Axum web framework
11+
#[http_service]
1212
async fn handler(req: Request) -> impl IntoResponse {
1313
Router::new()
1414
.route("/", get(root))

examples/wasip3-http-hello-world/spin.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ version = "1.0.0"
1111
[[trigger.http]]
1212
route = "/hello"
1313
component = "hello"
14+
executor = { type = "wasip3-unstable" }
1415

1516
[component.hello]
1617
source = "../../target/wasm32-wasip2/release/wasip3_hello_world.wasm"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use spin_sdk::http_wasip3::{http_component, Request};
1+
use spin_sdk::http_wasip3::{http_service, Request};
22

33
/// A simple Spin HTTP component.
4-
#[http_component]
4+
#[http_service]
55
async fn hello_world(_req: Request) -> &'static str {
66
"Hello, world!"
77
}

examples/wasip3-http-send-request/spin.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ version = "1.0.0"
1111
[[trigger.http]]
1212
route = "/..."
1313
component = "send"
14+
executor = { type = "wasip3-unstable" }
1415

1516
[component.send]
1617
source = "../../target/wasm32-wasip2/release/send_request.wasm"

examples/wasip3-http-send-request/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use spin_sdk::http_wasip3::{http_component, send, EmptyBody, IntoResponse, Request, Result};
1+
use spin_sdk::http_wasip3::{http_service, send, EmptyBody, IntoResponse, Request, Result};
22

33
/// Sends a request to a URL.
4-
#[http_component]
4+
#[http_service]
55
async fn send_request(_req: Request) -> Result<impl IntoResponse> {
66
let outgoing = http::Request::get("https://bytecodealliance.org").body(EmptyBody::new())?;
77

0 commit comments

Comments
 (0)