9 releases
new 0.1.8 | Jan 8, 2025 |
---|---|
0.1.7 | Jan 5, 2025 |
#229 in WebAssembly
829 downloads per month
Used in suika
180KB
3K
SLoC
suika_wasm
suika_wasm
is a middleware for the Suika web stack to serve pre-compiled
WebAssembly (Wasm) files.
Note: Suika is under active development and not intended for production use. The API is subject to change and may lack comprehensive testing and documentation.
use suika::server::{Server, Router};
use suika::middleware::WasmFileMiddleware;
use std::sync::Arc;
pub fn main() {
let mut server = Server::new("127.0.0.1:8080");
let mut router = Router::new("/");
router.get(r"/?$", |_req, res| {
Box::pin(async move {
res.set_status(201).await;
res.body("Hello World!".to_string()).await;
Ok(())
})
});
server.use_middleware(Arc::new(WasmFileMiddleware::new("/wasm", 86400)));
server.use_middleware(Arc::new(router));
server.run();
}
Dependencies
~6–13MB
~157K SLoC