pub mod compress;
pub mod debug;
pub mod extract;
pub mod handler;
pub mod health;
pub mod middleware;
pub mod multipart;
pub mod negotiate;
pub mod nextjs_bootstrap;
pub mod request_region;
pub mod response;
pub mod router;
pub mod security;
pub mod session;
pub mod sse;
pub mod static_files;
#[cfg(test)]
pub mod static_files_audit_test;
#[cfg(test)]
pub mod static_files_path_traversal_audit;
pub mod websocket;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub struct RequestBodyPolicy {
pub max_total_body_size: usize,
pub body_limits: extract::BodyLimits,
pub multipart_limits: multipart::MultipartLimits,
}
#[derive(Debug, Clone, Copy)]
pub(super) struct EnforcedRequestBodyPolicy {
pub(super) policy: RequestBodyPolicy,
}
impl Default for RequestBodyPolicy {
fn default() -> Self {
Self {
max_total_body_size: 16 * 1024 * 1024,
body_limits: extract::BodyLimits::default(),
multipart_limits: multipart::MultipartLimits::default(),
}
}
}
impl RequestBodyPolicy {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn max_total_body_size(mut self, bytes: usize) -> Self {
self.max_total_body_size = bytes;
self
}
#[must_use]
pub fn body_limits(mut self, limits: extract::BodyLimits) -> Self {
self.body_limits = limits;
self
}
#[must_use]
pub fn multipart_limits(mut self, limits: multipart::MultipartLimits) -> Self {
self.multipart_limits = limits;
self
}
#[must_use]
pub fn tightened_with(self, other: Self) -> Self {
Self {
max_total_body_size: self.max_total_body_size.min(other.max_total_body_size),
body_limits: self.body_limits.tightened_with(other.body_limits),
multipart_limits: self.multipart_limits.tightened_with(other.multipart_limits),
}
.resolved()
}
#[must_use]
pub fn resolved(self) -> Self {
let total = self.max_total_body_size;
let body_limits = self.body_limits.max_total_body_size(total);
let multipart_limits = self.multipart_limits.max_total_body_size(total);
Self {
max_total_body_size: total,
body_limits,
multipart_limits,
}
}
}
pub use extract::{
Accept, Authorization, ContentType, Cookie, CookieJar, Extension, Form, FromHeaderValue,
FromRequest, FromRequestParts, Header, HeaderParseError, Json as JsonExtract, Path, Query,
State, TypedHeader, UserAgent,
};
#[cfg(not(target_arch = "wasm32"))]
pub use extract::{CollectedStreamingRawBody, StreamingRawBody, StreamingRawBodyCollectError};
pub use handler::{
AsyncCxFnHandler, AsyncCxFnHandler1, AsyncCxFnHandler2, AsyncCxFnHandler3, AsyncCxFnHandler4,
AsyncCxFnHandler5, AsyncCxFnHandler6, AsyncCxFnHandler7, AsyncCxFnHandler8, FnHandler,
FnHandler1, FnHandler2, FnHandler3, FnHandler4, FnHandler5, FnHandler6, FnHandler7, FnHandler8,
FnHandler9, Handler,
};
pub use nextjs_bootstrap::{
BootstrapCommand, BootstrapLogEvent, BootstrapRecoveryAction, NextjsBootstrapConfig,
NextjsBootstrapError, NextjsBootstrapSnapshot, NextjsBootstrapState,
};
pub use response::{Html, IntoResponse, Json, Redirect, Response, StatusCode};
#[cfg(not(target_arch = "wasm32"))]
pub use response::{Http1StreamResponder, Http2StreamResponder};
#[cfg(all(feature = "http3", not(target_arch = "wasm32")))]
pub use response::{Http3BodySender, Http3StreamResponder};
#[cfg(not(target_arch = "wasm32"))]
pub use router::{Http1ProducedHandlerFuture, Http2ProducedHandlerFuture};
pub use router::{
HttpHandlerFuture, MethodRouter, RouteBodyPolicyInfo, RouteInfo, Router, delete, get, patch,
post, put,
};
#[cfg(all(feature = "http3", not(target_arch = "wasm32")))]
pub use router::{
NativeH3ProducedEvent, NativeH3Router, NativeH3RouterConfig, NativeH3RouterDispatch,
NativeH3RouterDispatchToken, NativeH3RouterEvent, NativeH3RouterIngress,
NativeH3RouterPreparedProducedResponse, NativeH3RouterPreparedResponse,
NativeH3RouterProducedDispatch, NativeH3RouterProducer, NativeH3RouterRefusal,
};
pub use sse::Http1SseResponse;