more shit.

This commit is contained in:
didier amyot committed 2023-02-05 20:13:24 -05:00
1 parent ba7763cbb1
commit e7cec774d8
4 files changed
+112 -28

No files matched your search

+9 -7
View File
@@ -3,6 +3,7 @@ use actix_web::http::header::q;
use clap::builder::TypedValueParser;
use minijinja::context;
use serde::Deserialize;
use std::collections::HashMap;
use crate::webui::MiniJinjaRenderer;
@@ -10,7 +11,6 @@ use crate::webui::MiniJinjaRenderer;
#[actix_web::get("/")]
pub async fn index(
tmpl_env: MiniJinjaRenderer,
query: web::Query<HashMap<String, String>>,
) -> actix_web::Result<impl Responder> {
tmpl_env.render("index.html", ())
}
@@ -18,7 +18,6 @@ pub async fn index(
#[actix_web::get("/actions")]
pub async fn actions(
tmpl_env: MiniJinjaRenderer,
query: web::Query<HashMap<String, String>>,
) -> actix_web::Result<impl Responder> {
tmpl_env.render("actions.html", ())
}
@@ -26,7 +25,6 @@ pub async fn actions(
#[actix_web::get("/overview")]
pub async fn overview(
tmpl_env: MiniJinjaRenderer,
query: web::Query<HashMap<String, String>>,
) -> actix_web::Result<impl Responder> {
tmpl_env.render("overview.html", ())
}
@@ -35,7 +33,7 @@ pub async fn overview(
pub async fn overview_submit_button(
req: HttpRequest,
tmpl_env: MiniJinjaRenderer,
query: web::Query<HashMap<String, String>>
query: web::Query<HashMap<String, String>>,
) -> actix_web::Result<impl Responder> {
let ctx = context! {
event_type => query.get("event_type").unwrap_or(&"".to_string()),
@@ -43,15 +41,19 @@ pub async fn overview_submit_button(
tmpl_env.render("partials/overview/submit_button.html", ctx)
}
#[derive(Deserialize, Debug)]
struct CreateEventPayload {
event: String,
event_type: String,
}
#[actix_web::post("/v1/events/{event_type}")]
pub async fn push_event(
req: HttpRequest,
tmpl_env: MiniJinjaRenderer,
query: web::Query<HashMap<String, String>>,
web::Form(form): web::Form<CreateEventPayload>,
) -> actix_web::Result<impl Responder> {
println!(">> {:?}", req);
let shit = req.match_info().get("event_type").unwrap();
let event = req.match_info().get("event").unwrap();
let ctx = context! {
event_type => shit,
};