pub struct BodyLimit { /* private fields */ }Expand description
Configuration for the request body size limit middleware.
Build with BodyLimit::new() and chain methods to set the byte limit or
error status code, then pass to BodyLimitLayer::new().
§Examples
use http::StatusCode;
use rune_axum_size::BodyLimit;
let config = BodyLimit::new()
.limit(10 * 1024 * 1024) // 10 MiB
.status(StatusCode::PAYLOAD_TOO_LARGE);Implementations§
Source§impl BodyLimit
impl BodyLimit
Sourcepub fn new() -> BodyLimit
pub fn new() -> BodyLimit
Creates a BodyLimit with defaults: 1 MiB limit, 413 Payload Too Large.
Sourcepub fn limit(self, bytes: u64) -> BodyLimit
pub fn limit(self, bytes: u64) -> BodyLimit
Sets the maximum allowed body size in bytes.
Defaults to 1 MiB (1,048,576 bytes).
Sourcepub fn status(self, status: StatusCode) -> BodyLimit
pub fn status(self, status: StatusCode) -> BodyLimit
Sets the HTTP status code returned when the limit is exceeded.
Defaults to 413 Payload Too Large.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BodyLimit
impl RefUnwindSafe for BodyLimit
impl Send for BodyLimit
impl Sync for BodyLimit
impl Unpin for BodyLimit
impl UnsafeUnpin for BodyLimit
impl UnwindSafe for BodyLimit
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