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
|
|
|
let json = web::JsonConfig::default().limit(*LIMIT);
|
|
|
|
let plain = web::PayloadConfig::default()
|
|
|
|
.limit(*LIMIT)
|
|
|
|
.mimetype(mime::STAR_STAR);
|
2022-03-01 00:53:47 +01:00
|
|
|
cfg.app_data(json).app_data(plain);
|
2021-12-20 17:42:16 +01:00
|
|
|
}
|