I need to make an API on Rust, to which you give a string, it performs some function, and then returns a new string. But an error occurred, if the string is too long, then an error occurs:
POST /test:
>> Matched: (test) POST /test
>> Data guard `String` failed: Custom { kind: UnexpectedEof, error: "data limit exceeded" }.
>> Outcome: Failure
>> No. 400 catcher registered. Using Rocket default.
>> Response succeeded.
rust code:
#[macro_use] extern crate rocket;
#[macro_use] extern crate serde_json;
#[get("/")]
fn index() -> String {
json!({"message": "Hello, world!"}).to_string()
}
#[post("/test", data = "<data>")]
fn test(data: String) -> String {
json!({"data": data}).to_string()
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![index, test])
}
cargo.toml:
[dependencies]
rocket = "0.5.0-rc.3"
serde_json = "1.0.64"
rocket_sync_db_pools = "0.1.0-rc.3"
serde = { version = "1.0", features = ["derive"] }
rocket_contrib = "0.4.11"
I tried to solve the problem with ChatGPT and perplexity ai but they didn't help