worker_route

Attribute Macro head

Source
#[head]
Expand description

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

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

§Usage

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

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