pub struct IpFilterLayer { /* private fields */ }Expand description
Tower Layer that applies CIDR-based IP allowlist or blocklist filtering.
Apply with Axum’s .layer() call. Use IpFilterLayer::new() with a configured
IpFilterConfig to set your CIDR ranges and filter mode.
[!NOTE] Requests where the client IP cannot be extracted (header absent or unparseable) pass through unchecked regardless of mode.
§Examples
use axum::{routing::get, Router};
use rune_axum_ipfilter::{FilterMode, IpFilterConfig, IpFilterLayer};
let app: Router = Router::new()
.route("/api", get(|| async { "ok" }))
.layer(IpFilterLayer::new(
IpFilterConfig::new()
.mode(FilterMode::Blocklist)
.cidr("192.168.1.100/32"),
));Implementations§
Source§impl IpFilterLayer
impl IpFilterLayer
Sourcepub fn new(config: IpFilterConfig) -> IpFilterLayer
pub fn new(config: IpFilterConfig) -> IpFilterLayer
Creates an IpFilterLayer from a custom IpFilterConfig.
Trait Implementations§
Source§impl Clone for IpFilterLayer
impl Clone for IpFilterLayer
Source§fn clone(&self) -> IpFilterLayer
fn clone(&self) -> IpFilterLayer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IpFilterLayer
impl Debug for IpFilterLayer
Source§impl<S> Layer<S> for IpFilterLayer
impl<S> Layer<S> for IpFilterLayer
Source§type Service = IpFilterService<S>
type Service = IpFilterService<S>
The wrapped service
Auto Trait Implementations§
impl !Freeze for IpFilterLayer
impl RefUnwindSafe for IpFilterLayer
impl Send for IpFilterLayer
impl Sync for IpFilterLayer
impl Unpin for IpFilterLayer
impl UnsafeUnpin for IpFilterLayer
impl UnwindSafe for IpFilterLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more