Expand description
Request filtering module that provides composable request filters.
This module implements a filter system that allows you to:
- Filter requests based on HTTP methods
- Filter requests based on headers
- Combine multiple filters using AND/OR logic
- Create custom filters using closures
§Thread Safety
All filters must implement the Filter trait, which requires Send + Sync.
This ensures that filters can be safely shared and used across threads,
which is essential for concurrent request handling in a web server environment.
§Examples
use micro_web::router::filter::{all_filter, any_filter, get_method, header};
// Create a filter that matches GET requests
let get_filter = get_method();
// Create a filter that checks for specific header
let auth_filter = header("Authorization", "Bearer token");
// Combine filters with AND logic
let mut combined = all_filter();
combined.and(get_filter).and(auth_filter);Structs§
- AllFilter
- Compose filters with AND logic.
- AnyFilter
- Compose filters with OR logic.
- False
Filter - A filter that always returns false.
- Header
Filter - A filter that matches HTTP headers.
- Method
Filter - A filter that matches HTTP methods.
- True
Filter - A filter that always returns true.
Traits§
- Filter
- Core trait for request filtering.
Functions§
- all_
filter - Creates a new AND-composed filter chain.
- any_
filter - Creates a new OR-composed filter chain.
- connect_
method - Creates a filter that matches HTTP CONNECT requests.
- delete_
method - Creates a filter that matches HTTP DELETE requests.
- false_
filter - Creates a filter that always returns false.
- filter_
fn - Creates a new filter from a closure.
- get_
method - Creates a filter that matches HTTP GET requests.
- head_
method - Creates a filter that matches HTTP HEAD requests.
- header
- Creates a filter that matches a specific header name and value.
- options_
method - Creates a filter that matches HTTP OPTIONS requests.
- patch_
method - Creates a filter that matches HTTP PATCH requests.
- post_
method - Creates a filter that matches HTTP POST requests.
- put_
method - Creates a filter that matches HTTP PUT requests.
- trace_
method - Creates a filter that matches HTTP TRACE requests.
- true_
filter - Creates a filter that always returns true.