started howto module to provide basic examples and explore possibilities

This commit is contained in:
2023-10-04 00:46:44 +02:00
parent e78a06547a
commit f010ee0f47
7 changed files with 84 additions and 35 deletions
+9
View File
@@ -0,0 +1,9 @@
use axum::{routing::get, Router};
use crate::state::AppState;
pub mod views;
pub fn routes() -> Router<AppState> {
Router::new().route("/", get(views::howtos).post(views::answer_question))
}
+17
View File
@@ -0,0 +1,17 @@
use axum::{extract::State, response::IntoResponse, Form};
use crate::service::templates;
use serde::Deserialize;
#[derive(Deserialize)]
pub struct Question {
question: String,
}
pub async fn howtos(templates: State<templates::Templates>) -> impl IntoResponse {
templates.render_html("howto/index.html", ())
}
pub async fn answer_question(Form(question): Form<Question>) -> impl IntoResponse {
"There is your answer!".to_owned()
}