mirror of
https://github.com/supleed2/cch23-8bit.git
synced 2024-11-10 03:35:47 +00:00
38 lines
812 B
Rust
38 lines
812 B
Rust
use axum::{response::IntoResponse, routing::post, Json, Router};
|
|
|
|
pub(crate) fn router() -> Router {
|
|
Router::new()
|
|
.route("/14/unsafe", post(unsafefn))
|
|
.route("/14/safe", post(safefn))
|
|
}
|
|
|
|
#[derive(serde::Deserialize)]
|
|
struct Content {
|
|
content: String,
|
|
}
|
|
|
|
#[derive(askama::Template)]
|
|
#[template(path = "day14/index.html", escape = "none")]
|
|
struct UnsafeTemplate {
|
|
content: String,
|
|
}
|
|
|
|
async fn unsafefn(Json(content): Json<Content>) -> impl IntoResponse {
|
|
UnsafeTemplate {
|
|
content: content.content,
|
|
}
|
|
}
|
|
|
|
#[derive(askama::Template)]
|
|
#[template(path = "day14/index.html")]
|
|
struct SafeTemplate {
|
|
content: String,
|
|
}
|
|
|
|
#[axum::debug_handler]
|
|
async fn safefn(Json(content): Json<Content>) -> impl IntoResponse {
|
|
SafeTemplate {
|
|
content: content.content,
|
|
}
|
|
}
|