#[derive(Clone, Debug)]
pub struct RequestLimits {
pub max_body_bytes: usize,
pub max_field_count: usize,
pub max_nesting_depth: usize,
}
impl Default for RequestLimits {
fn default() -> Self {
Self {
max_body_bytes: 1024 * 1024, max_field_count: 100,
max_nesting_depth: 10,
}
}
}
impl RequestLimits {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn with_max_body_bytes(mut self, max: usize) -> Self {
self.max_body_bytes = max;
self
}
#[must_use]
pub fn with_max_field_count(mut self, max: usize) -> Self {
self.max_field_count = max;
self
}
#[must_use]
pub fn with_max_nesting_depth(mut self, max: usize) -> Self {
self.max_nesting_depth = max;
self
}
}