aboutsummaryrefslogtreecommitdiffstats
path: root/src/web_server/default.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/web_server/default.rs')
-rw-r--r--src/web_server/default.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/web_server/default.rs b/src/web_server/default.rs
new file mode 100644
index 0000000..b3c8291
--- /dev/null
+++ b/src/web_server/default.rs
@@ -0,0 +1,24 @@
+use actix::Addr;
+use actix_web::{web, Error, HttpResponse};
+use askama::actix_web::TemplateIntoResponse;
+use askama::Template;
+
+use crate::web_server::{filters, BotData, BotDataListRequest, BotExecutor};
+
+#[derive(Template)]
+#[template(path = "index.htm")]
+struct OverviewTemplate<'a> {
+ bots: &'a [BotData],
+}
+
+pub async fn index(bot: web::Data<Addr<BotExecutor>>) -> Result<HttpResponse, Error> {
+ let bot_datas = match bot.send(BotDataListRequest).await.unwrap() {
+ Ok(data) => data,
+ Err(_) => Vec::with_capacity(0),
+ };
+
+ OverviewTemplate {
+ bots: &bot_datas[..],
+ }
+ .into_response()
+}