feat: embed htmx

This commit is contained in:
Jef Roosens 2024-12-28 15:25:13 +01:00
parent 35f1433e40
commit 412f4cd2c7
No known key found for this signature in database
GPG key ID: 21FD3D77D56BAF49
6 changed files with 128 additions and 10 deletions

View file

@ -30,10 +30,15 @@ impl TryFrom<&Row<'_>> for Plant {
}
pub fn app(ctx: crate::Context) -> axum::Router {
Router::new()
let mut router = Router::new()
.route("/", get(get_index))
.route("/plants", post(post_plants))
.with_state(ctx)
.route("/plants", post(post_plants));
for (name, content) in crate::STATIC_FILES {
router = router.route(&format!("/static/{}", name), get(content))
}
router.with_state(ctx)
}
async fn get_index(State(ctx): State<crate::Context>) -> Html<String> {