worker_route

Attribute Macro patch

Source
#[patch]
Expand description

A macro that creates route handler with worker::Router::patch

worker::Router::patch_async will be used if the handler is an async fn.

§Usage

#[patch("/path")]

§Attributes

  • "path": Worker’s path.
  • Option<cors>: Wrap a struct that implements worker_route::MwService.
  • Option<lazy_cors>: Wrap a lazy initialized Cors.
  • Option<wrap>: Register an options handler with the provided cors. Defaults to None.

§Examples

use worker::{Result, Request, RouteContext, Response};
use worker_route::patch;

#[patch("/path")]
async fn foo(req: Request, ctx: RouteContext<()>) -> Result<Response>{
    Response::empty()
}