add payload limit to app config

This commit is contained in:
marin postma 2021-06-23 13:58:22 +02:00
parent 1c13100948
commit 4b292c6e9b
No known key found for this signature in database
GPG Key ID: 6088B7721C3E39F9

View File

@ -28,7 +28,7 @@ pub fn configure_data(config: &mut web::ServiceConfig, data: Data) {
.content_type(|_mime| true) // Accept all mime types
.error_handler(|err, _req| error::payload_error_handler(err).into()),
)
.app_data(web::PayloadConfig::new(http_payload_size_limit))
.app_data(PayloadConfig::new(http_payload_size_limit))
.app_data(
web::QueryConfig::default()
.error_handler(|err, _req| error::payload_error_handler(err).into()),
@ -116,6 +116,10 @@ pub struct PayloadConfig {
limit: usize,
}
impl PayloadConfig {
pub fn new(limit: usize) -> Self { Self { limit } }
}
impl Default for PayloadConfig {
fn default() -> Self {
Self { limit: 256 * 1024 }