Skip to content

HTTP middleware using WASIp3#3384

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

HTTP middleware using WASIp3#3384
itowlson wants to merge 3 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 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
itowlson and others added 2 commits February 17, 2026 14:53
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@itowlson
Copy link
Collaborator Author

Updated to rework OCI precomposition. The way I did it before resulted in two code paths which were essentially the same but couldn't be exactly the same. Now there is only one code path and it is exactly the same as itself.

I am getting increasingly fearful that I am getting lost in a labyrinth of my own changes and although it all seems to work for me I would really value somebody else looking at it and kicking the tyres because what if I am not testing it right. I was sure that this last rework had broken something, and yet seemingly not, which makes me worry whether I am testing what I think I'm testing.

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