pub struct HostFilterLayer(/* private fields */);
Expand description
Middleware to enable host filtering.
Implementations§
source§impl HostFilterLayer
impl HostFilterLayer
sourcepub fn new<T, U>(allow_only: T) -> Result<Self, AuthorityError>
pub fn new<T, U>(allow_only: T) -> Result<Self, AuthorityError>
Enables host filtering and allow only the specified hosts.
sourcepub fn disable() -> Self
pub fn disable() -> Self
Convenience method to disable host filtering but less efficient than to not enable the middleware at all.
Because is the tower middleware
returns a different type
depending on which Layers are configured it and may not compile
in some contexts.
For example the following won’t compile:
ⓘ
use jsonrpsee_server::middleware::{ProxyGetRequestLayer, HostFilterLayer};
let host_filter = false;
let middleware = if host_filter {
tower::ServiceBuilder::new()
.layer(HostFilterLayer::new(["example.com"]).unwrap())
.layer(ProxyGetRequestLayer::new("/health", "system_health").unwrap())
} else {
tower::ServiceBuilder::new()
};
Trait Implementations§
source§impl Clone for HostFilterLayer
impl Clone for HostFilterLayer
source§fn clone(&self) -> HostFilterLayer
fn clone(&self) -> HostFilterLayer
Returns a copy 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 HostFilterLayer
impl Debug for HostFilterLayer
Auto Trait Implementations§
impl Freeze for HostFilterLayer
impl RefUnwindSafe for HostFilterLayer
impl Send for HostFilterLayer
impl Sync for HostFilterLayer
impl Unpin for HostFilterLayer
impl UnwindSafe for HostFilterLayer
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)