refactor: let actix handle String conversion

main
Carsten Kragelund 2023-07-28 20:29:21 +02:00
parent 8eba4a1b4d
commit a8000cd0f3
Signed by: nyx
GPG Key ID: CADDADEEC9F753C0
1 changed files with 2 additions and 4 deletions

@ -1,4 +1,3 @@
use rapid_web::actix::web::Bytes;
use rapid_web::actix::HttpResponse;
use rapid_web::rapid_web_codegen::rapid_handler;
@ -6,8 +5,7 @@ pub const ROUTE_KEY: &str = "echo";
pub type RapidOutput = String;
#[rapid_handler]
pub async fn post(bytes: Bytes) -> HttpResponse {
let body = String::from_utf8(bytes.to_vec()).unwrap();
println!("Body: {}", &body);
pub async fn post(body: String) -> HttpResponse {
println!("Body: {}", body);
HttpResponse::Ok().body(body)
}