pub struct BodyLimitLayer { /* private fields */ }Expand description
Tower Layer that rejects requests whose Content-Length exceeds the configured limit.
Apply with Axum’s .layer() call. Use BodyLimitLayer::default() for a 1 MiB limit
with a 413 response, or BodyLimitLayer::new() to supply a custom BodyLimit.
[!NOTE] Only the
Content-Lengthheader is inspected. Requests that omit this header pass through regardless of their actual body size.
§Examples
use axum::{routing::post, Router};
use rune_axum_size::BodyLimitLayer;
let app: Router = Router::new()
.route("/upload", post(|| async { "ok" }))
.layer(BodyLimitLayer::default());Implementations§
Source§impl BodyLimitLayer
impl BodyLimitLayer
Sourcepub fn new(config: BodyLimit) -> BodyLimitLayer
pub fn new(config: BodyLimit) -> BodyLimitLayer
Creates a BodyLimitLayer from a custom BodyLimit configuration.
Trait Implementations§
Source§impl Clone for BodyLimitLayer
impl Clone for BodyLimitLayer
Source§fn clone(&self) -> BodyLimitLayer
fn clone(&self) -> BodyLimitLayer
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 BodyLimitLayer
impl Debug for BodyLimitLayer
Source§impl Default for BodyLimitLayer
impl Default for BodyLimitLayer
Source§fn default() -> BodyLimitLayer
fn default() -> BodyLimitLayer
Returns the “default value” for a type. Read more
Source§impl<S> Layer<S> for BodyLimitLayer
impl<S> Layer<S> for BodyLimitLayer
Source§type Service = BodyLimitService<S>
type Service = BodyLimitService<S>
The wrapped service
Auto Trait Implementations§
impl Freeze for BodyLimitLayer
impl RefUnwindSafe for BodyLimitLayer
impl Send for BodyLimitLayer
impl Sync for BodyLimitLayer
impl Unpin for BodyLimitLayer
impl UnsafeUnpin for BodyLimitLayer
impl UnwindSafe for BodyLimitLayer
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