1 stable release
1.0.0 | Dec 10, 2024 |
---|
#1059 in Network programming
148 downloads per month
6KB
88 lines
HTTP router for Cloudflare Workers
Example using the worker
:
struct ServerState {}
async fn get_hello(_req: Request, _state: Arc<ServerState>) -> Result<Response> {
ResponseBuilder::new().ok("hello")
}
#[event(fetch)]
async fn fetch(req: Request, _env: Env, _ctx: Context) -> Result<Response> {
let state = Arc::new(ServerState {});
let router = router::Router::new_with_state(state).get(router::path("/hello")?, get_hello);
router.run(req).await
}
Dependencies
~17–27MB
~395K SLoC