Skip to content

HTTP middleware using WASIp3#3384

Draft
itowlson wants to merge 1 commit intospinframework:mainfrom
itowlson:http-middleware-final-final-v2
Draft

HTTP middleware using WASIp3#3384
itowlson wants to merge 1 commit intospinframework:mainfrom
itowlson:http-middleware-final-final-v2

Conversation

@itowlson
Copy link
Collaborator

@itowlson itowlson commented Feb 3, 2026

Fixes #3291.

This currently includes #3383; once that lands I will rebase. For now just ignore the wit directory. Done!

Example usage: https://github.com/itowlson/spin-middleware-terrifying-nonsense

Setting it up in spin.toml:

[[trigger.http]]
route = "/..."
component = "middleware-terrifying-nonsense"
components.middleware = ["middlybiddly", "middlybiddly2"]
executor = { type = "wasip3-unstable" }

Implementing a middleware component in Rust (today: we'd presumably provide a wrapper for the onbound handle import):

#[spin_sdk::http_wasip3::http_service]
async fn handle(mut request: Request) -> impl IntoResponse {
    munge(&mut request);
    wasi::http0_3_0_rc_2026_01_06::handler::handle(request.into_request().unwrap()).await
    // could process the response here if needed
}

Needs lots of renaming, tests, etc. but anyway getting it into the system. (and yes, yes, I'll squash the commits)

@itowlson itowlson force-pushed the http-middleware-final-final-v2 branch 2 times, most recently from 76ccf41 to 0371b3c Compare February 4, 2026 22:03
@fibonacci1729 fibonacci1729 moved this to Backlog in Spin 4.0 Feb 10, 2026
@itowlson itowlson force-pushed the http-middleware-final-final-v2 branch from 0371b3c to 6d30b34 Compare February 11, 2026 21:13
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@itowlson itowlson force-pushed the http-middleware-final-final-v2 branch from 6d30b34 to 654d07b Compare February 15, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

WASI P3 HTTP middleware

1 participant