worker-router 1.0.0

HTTP router for Cloudflare Workers
Documentation
  • Coverage
  • 87.5%
    14 out of 16 items documented11 out of 15 items with examples
  • Size
  • Source code size: 5.41 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 846.72 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 52s Average build duration of successful builds.
  • all releases: 52s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • xtuc/worker-router
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • xtuc

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
}