Worker Route is a crate designed for usage in Cloudflare Workers.
```rust use serde::{Deserialize, Serialize}; use worker::{event, Env, Request, Response, Result, RouteContext, Router}; use worker_route::{get, Configure, Query, Service};
struct Bar { bar: String, }
async fn bar(req: Query
struct Foo { foo: String, }
async fn foo(req: Query
struct FooBar { foo: String, bar: String, }
// your function can consists of (Query
async fn foobar(req: Query
struct Person { name: String, age: usize, }
async fn person(req: Query
fn initroutes(router: Router<'static, ()>) -> Router<'static, ()> { router .configure(bar) .configure(foo) .configure(person) .configure(foobar) }
pub async fn main(req: Request, env: Env, ctx: worker::Context) -> Result
Currently only async methods are supported.
If you have a synchronous get method, it will be set to .get_async()
instead of .get()
.
License: Apache-2.0