[][src]Crate actix_web_codegen

Helper and convenience macros for Actix-web.

Runtime Setup

Resource Macros:

Attributes:

  • "path" - Raw literal string with path for which to register handle. Mandatory.
  • guard="function_name" - Registers function as guard using actix_web::guard::fn_guard
  • wrap="Middleware" - Registers a resource middleware.

Notes

Function name can be specified as any expression that is going to be accessible to the generate code (e.g my_guard or my_module::my_guard)

Example:

use actix_web::HttpResponse;
use actix_web_codegen::get;

#[get("/test")]
async fn async_test() -> Result<HttpResponse, actix_web::Error> {
    Ok(HttpResponse::Ok().finish())
}

Attribute Macros

connect

Creates route handler with CONNECT method guard.

delete

Creates route handler with DELETE method guard.

get

Creates route handler with GET method guard.

head

Creates route handler with HEAD method guard.

main

Marks async main function as the actix system entry-point.

options

Creates route handler with OPTIONS method guard.

patch

Creates route handler with PATCH method guard.

post

Creates route handler with POST method guard.

put

Creates route handler with PUT method guard.

trace

Creates route handler with TRACE method guard.