Skip to content

HTTP middleware using WASIp3#3384

Draft
itowlson wants to merge 8 commits intospinframework:mainfrom
itowlson:http-middleware-final-final-v2
Draft

HTTP middleware using WASIp3#3384
itowlson wants to merge 8 commits 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 from 6ce9690 to 76ccf41 Compare February 3, 2026 20:22
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
…deduplicated and there is fractionally less read-it-in-then-write-it-out again

Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@itowlson itowlson force-pushed the http-middleware-final-final-v2 branch from 76ccf41 to 0371b3c Compare February 4, 2026 22:03
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.

WASI P3 HTTP middleware

1 participant