cryptgeon/backend/src/size.rs

21 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! {
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-20 17:42:16 +01:00
pub fn init(cfg: &mut web::ServiceConfig) {
2021-12-22 13:10:08 +01:00
println!("Limit: {}", *LIMIT);
let json = web::JsonConfig::default().limit(*LIMIT);
let plain = web::PayloadConfig::default()
.limit(*LIMIT)
.mimetype(mime::STAR_STAR);
cfg.data(json);
cfg.data(plain);
2021-12-20 17:42:16 +01:00
}