aboutsummaryrefslogtreecommitdiff
path: root/crates/whirl_api/src/routes/worlds/info/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/whirl_api/src/routes/worlds/info/mod.rs')
-rw-r--r--crates/whirl_api/src/routes/worlds/info/mod.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/whirl_api/src/routes/worlds/info/mod.rs b/crates/whirl_api/src/routes/worlds/info/mod.rs
index 6ea1453..ea04112 100644
--- a/crates/whirl_api/src/routes/worlds/info/mod.rs
+++ b/crates/whirl_api/src/routes/worlds/info/mod.rs
@@ -1,22 +1,19 @@
// Copyright (C) 2021-2021 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only
-use std::str::from_utf8;
-
-use actix_web::{HttpRequest, HttpResponse};
+#[derive(Serialize, Deserialize)]
+pub struct Parameters {
+ username: Option<String>,
+}
-// error: this argument is passed by value, but not consumed in the function
-// body
-#[allow(clippy::needless_pass_by_value)]
-pub fn info(req: HttpRequest) -> HttpResponse {
+#[allow(clippy::needless_pass_by_value, clippy::unused_async)]
+pub async fn info(axum::extract::Query(req): axum::extract::Query<Parameters>) -> &'static str {
let mut easy = curl::easy::Easy::new();
easy
.url(&format!(
"http://www-dynamic.us.worlds.net/cgi-bin/profile.pl?{}",
- qstring::QString::from(req.query_string())
- .get("username")
- .unwrap_or(""),
+ req.username.as_ref().unwrap_or(&"".to_string()),
))
.unwrap();
@@ -34,5 +31,5 @@ pub fn info(req: HttpRequest) -> HttpResponse {
transfer.perform().unwrap();
}
- HttpResponse::Ok().body(from_utf8(&response).unwrap().to_string())
+ Box::leak(String::from_utf8(response).unwrap().into_boxed_str())
}