Skip to content

Commit 70042c3

Browse files
authored
Merge pull request #259 from doyoubi/FixLargePayload
Fix large payload
2 parents 6aa4dca + 53cc7e5 commit 70042c3

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/bin/mem_broker.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use undermoon::broker::{
1919
#[global_allocator]
2020
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
2121

22-
const MAX_PAYLOAD: usize = 128 * 1024 * 1024;
23-
2422
fn gen_conf() -> MemBrokerConfig {
2523
let mut s = config::Config::new();
2624
if let Some(conf_file_path) = env::args().nth(1) {
@@ -190,8 +188,6 @@ async fn main() -> std::io::Result<()> {
190188
HttpServer::new(move || {
191189
let service = service.clone();
192190
App::new()
193-
.data(actix_web::web::PayloadConfig::default().limit(MAX_PAYLOAD))
194-
.data(actix_web::web::JsonConfig::default().limit(MAX_PAYLOAD))
195191
.wrap(middleware::Logger::default())
196192
.configure(|cfg| configure_app(cfg, service.clone()))
197193
})

src/broker/service.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ use std::sync::{Arc, RwLock};
2323
use std::time::Duration;
2424

2525
pub const MEM_BROKER_API_VERSION: &str = "/api/v2";
26+
const MAX_PAYLOAD: usize = 128 * 1024 * 1024;
2627

2728
pub fn configure_app(cfg: &mut web::ServiceConfig, service: Arc<MemBrokerService>) {
2829
let service2 = service.clone();
2930
cfg.data(service).service(
3031
web::scope(MEM_BROKER_API_VERSION)
32+
.app_data(actix_web::web::PayloadConfig::default().limit(MAX_PAYLOAD))
33+
.app_data(actix_web::web::JsonConfig::default().limit(MAX_PAYLOAD))
3134
.wrap_fn(move |req, srv| {
3235
let method = req.method().clone();
3336
let peer_addr = match req.peer_addr() {

0 commit comments

Comments
 (0)