-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
day14.rs
37 lines (31 loc) · 812 Bytes
/
day14.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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,
}
}