Crates.io | waserv |
lib.rs | waserv |
version | 0.1.4 |
source | src |
created_at | 2020-12-26 11:19:34.312945 |
updated_at | 2020-12-26 11:19:34.312945 |
description | waserv |
homepage | |
repository | https://github.com/mehmetcansahin/waserv |
max_upload_size | |
id | 327447 |
size | 10,040 |
Waserv is a simple web server for a wasm
Request -> CF Worker -> Waserv -> Response
## Example
use web_sys::{Request, Response, Headers};
use waserv::{response::response, router::Router, Params, Waserv};
fn index(_request: Request, _params: Params) -> Response {
let body = "Hello, World!".to_string();
let headers = Headers::new().unwrap();
headers
.set("Content-Type", "text/html; charset=UTF-8")
.unwrap();
headers.set("Cache-Control", "no-cache").unwrap();
response(body, headers, Some(200))
}
fn handle(request: Request) -> Response {
let mut router = Router::new();
router.get("/", Box::new(index));
let mut ww = Waserv::new();
ww.mount(router);
ww.handle(request)
}
wasm-pack test --chrome