#[route]Expand description
A macro that creates route handler with multiple methods.
§Usage
#[route("path", method = "method", cors = "cors", lazy_cors = "lazy_cors", wrap)]§Attributes
"path": Worker’s path.method: An array of methods or a method in string literal.Option<cors>: Wrap a struct that implementsworker_route::MwService.Option<lazy_cors>: Wrap a lazy initialized Cors.Option<wrap>: Register an options handler with the provided cors. Defaults toNone.
§Examples
use worker::{Result, Request, RouteContext, Response};
use worker_route::route;
#[route("/path", method = "get", method = "post")]
async fn foo(req: Request, ctx: RouteContext<()>) -> Result<Response> {
Response::empty()
}