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