ztp/src/user.rs

14 lines
399 B
Rust

use axum::{http::StatusCode, response::IntoResponse, Form};
#[derive(serde::Deserialize)]
pub struct FormData {
username: String,
}
pub async fn index(payload: Option<Form<FormData>>) -> impl IntoResponse {
let username = payload.map_or("World !".to_string(), move |index| -> String {
String::from(&(index.username))
});
(StatusCode::OK, format!("Hello, {}", &username))
}