actix-responder-macro
An attribute macro to transform
a handler response struct to an actix responder
.
Keeps flexibility while adding more type safety.
The actix_responder
adds 2 additional fields to your struct
content_type
and status_code
.
The meta_attr
allows for arbitrary attributes to both fields.
status_attr
applies only to status_code
and content_attr
applies only to content_type
The reason for this is like in the example below, if you use
a crate like TypedBuilder
, you might want to apply options like
#[builder(default)]
to the generated field.
The macro always applies #[serde(skip)]
to both generated fields
so they won't show up in the request response.
From this
pub async
to this
pub async
A more complicated example with setting default values
extern crate actix_responder_macro;
extern crate mime;
extern crate typed_builder;
use actix_responder;
use StatusCode;
use ;
use TypedBuilder;