Skip to content

Commit

Permalink
feat: increase json size limit to 10MB
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobLinCool committed Jun 3, 2023
1 parent b4df83d commit 9cda0a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/server/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::server::compress;
use crate::server::execute;
use crate::server::judge;
use crate::server::jwt;
use rocket::data::ByteUnit;
use rocket::serde::{json::Json, Deserialize, Serialize};
use rocket::Build;
use rocket::Config;
Expand Down Expand Up @@ -35,10 +36,14 @@ fn info() -> Json<ServerInfo> {

/// Get the Rocket instance
pub fn rocket() -> Rocket<Build> {
let json_limit: ByteUnit = "10MB".parse().unwrap();
let limits = Config::default().limits.limit("json", json_limit);

let server = rocket::build()
.configure(Config {
address: Ipv4Addr::new(0, 0, 0, 0).into(),
port: server_port(),
limits,
..Config::default()
})
.mount(
Expand Down
8 changes: 6 additions & 2 deletions src/server/judge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ pub async fn judge(
let result = run_specs(wasm, submission.specs).await;
let client = Client::new();
match client.post(&callback).json(&result).send().await {
Ok(_) => {
println!("Callback sent successfully. ({})", &callback);
Ok(res) => {
println!(
"Callback sent successfully. {} ({})",
res.status(),
&callback
);
}
Err(e) => {
println!("Error sending callback. {} ({})", e, &callback);
Expand Down

0 comments on commit 9cda0a1

Please sign in to comment.