allow max payload size override

This commit is contained in:
marinpostma 2020-05-14 17:52:10 +02:00 committed by mpostma
parent e40d9e7462
commit 5193382b07
3 changed files with 9 additions and 1 deletions

View File

@ -35,6 +35,7 @@ pub struct DataInner {
pub db_path: String,
pub api_keys: ApiKeys,
pub server_pid: Pid,
pub http_payload_size_limit: usize,
}
#[derive(Clone)]
@ -137,6 +138,8 @@ impl Data {
update_map_size: opt.update_map_size,
};
let http_payload_size_limit = opt.http_payload_size_limit;
let db = Arc::new(Database::open_or_create(opt.db_path, db_opt).unwrap());
let mut api_keys = ApiKeys {
@ -152,6 +155,7 @@ impl Data {
db_path,
api_keys,
server_pid,
http_payload_size_limit,
};
let data = Data {

View File

@ -31,7 +31,7 @@ pub fn create_app(
.app_data(web::Data::new(data.clone()))
.app_data(
web::JsonConfig::default()
.limit(1024 * 1024 * 10) // Json Limit of 10Mb
.limit(data.http_payload_size_limit)
.content_type(|_mime| true) // Accept all mime types
.error_handler(|err, _req| json_error_handler(err).into()),
)

View File

@ -34,4 +34,8 @@ pub struct Opt {
/// The maximum size, in bytes, of the update lmdb database directory
#[structopt(long, env = "MEILI_UPDATE_MAP_SIZE", default_value = "107374182400")] // 100GB
pub update_map_size: usize,
/// The maximum size, in bytes, of accepted JSON payloads
#[structopt(long, env = "MEILI_HTTP_PAYLOAD_SIZE_LIMIT", default_value = "10485760")] // 10MB
pub http_payload_size_limit: usize,
}