#[derive(RequestFilter)]
Expand description
This macro will automatically implement RequestFilter
by chaining the handlers identified
in the struct’s fields.
Each handler has to implement RequestFilter
trait. The handlers will be called in the order
in which they are listed. Each handler can prevent the subsequent handlers from being called by
returning RequestFilterResult::ResponseSent
or RequestFilterResult::Handled
.
The configuration and context for the struct will be implemented implicitly. These will have the configuration/context of the respective handler in a field with the same name as the handler in this struct.
use module_utils::{FromYaml, RequestFilter};
use compression_module::CompressionHandler;
use static_files_module::StaticFilesHandler;
#[derive(Debug, RequestFilter)]
struct Handler {
compression: CompressionHandler,
static_files: StaticFilesHandler,
}
type Conf = <Handler as RequestFilter>::Conf;
let conf = Conf::load_from_yaml("test.yaml").ok().unwrap_or_else(Conf::default);
let handler: Handler = conf.try_into().unwrap();