worker_route

Attribute Macro options

Source
#[options]
Expand description

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

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

§Usage

#[options("/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::options;

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