The web framework: an HTTP/1.1 keep-alive server core, a router with :param captures, and Handler/Middleware structural interfaces.
Add it to your wo.toml. The
KEY is the module name — that is what use imports.
[deps]
serve = { git = "https://github.com/shoneyj/writeonce-serve", rev = "v0.1.0" }App — the route table and the middleware chains; app.get/post/delete_, use_mw, use_after, mount, serve.StaticFiles — serve a directory over a wildcard route. Traversal is refused, not normalised; max_bytes is a hard ceiling. This site's /dl downloads run through it.Handler, Middleware, After — structural interfaces. A handler is a CLASS; its fields are the closure this language does not have.Req/Resp plus builders: ok_text, ok_html, ok_json, created_json, not_found, bad_request, unauthorized, conflict, redirect.bearer_token, basic_credentials, constant-time ct_eq. Which routes are gated stays your policy.form_values, multipart_parts, content negotiation, ETags, security headers, CORS, WebSocket frames.use serve
use serve/http
use serve/router
class Hello {
fn handle(req: Req) -> Resp {
return ok_text("hello");
}
}
fn main(args: multi Text) -> Int {
let app = App { middleware: [], routes: [] };
app.use_mw(Mw { m: Logging {} });
app.get("/", Hello {});
return app.serve("127.0.0.1", 8080);
}