cryptgeon/backend/src/size.rs

19 lines
492 B
Rust
Raw Normal View History

2021-12-20 17:42:16 +01:00
use actix_web::web;
use byte_unit::Byte;
2021-12-22 13:10:08 +01:00
use mime;
lazy_static! {
2022-03-12 14:07:33 +01:00
pub static ref LIMIT: usize =
Byte::from_str(std::env::var("SIZE_LIMIT").unwrap_or("1 KiB".to_string()))
.unwrap()
.get_bytes() as usize;
2021-12-22 13:10:08 +01:00
}
2021-12-20 17:42:16 +01:00
pub fn init(cfg: &mut web::ServiceConfig) {
2022-03-12 14:07:33 +01:00
let json = web::JsonConfig::default().limit(*LIMIT);
let plain = web::PayloadConfig::default()
.limit(*LIMIT)
.mimetype(mime::STAR_STAR);
cfg.app_data(json).app_data(plain);
2021-12-20 17:42:16 +01:00
}