From 4e1c2b9f04073294ecb8402486c20d9c01721598 Mon Sep 17 00:00:00 2001 From: Jokler Date: Wed, 14 Oct 2020 00:19:27 +0200 Subject: Replace channels&locks with actors & log with slog --- src/web_server/tmtu.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/web_server/tmtu.rs') diff --git a/src/web_server/tmtu.rs b/src/web_server/tmtu.rs index 33a14af..e9eea98 100644 --- a/src/web_server/tmtu.rs +++ b/src/web_server/tmtu.rs @@ -1,9 +1,9 @@ -use actix::Addr; use actix_web::{http::header, web, Error, HttpResponse}; -use askama::Template; -use askama_actix::TemplateIntoResponse; +use askama_actix::{Template, TemplateIntoResponse}; +use xtra::WeakAddress; -use crate::web_server::{filters, BotData, BotDataRequest, BotExecutor, BotNameListRequest}; +use crate::web_server::{filters, BotData, BotDataRequest, BotNameListRequest}; +use crate::MasterBot; #[derive(Template)] #[template(path = "tmtu/index.htm")] @@ -12,8 +12,8 @@ struct TmtuTemplate { bot: Option, } -pub async fn index(bot: web::Data>) -> Result { - let bot_names = bot.send(BotNameListRequest).await.unwrap().unwrap(); +pub async fn index(bot: web::Data>) -> Result { + let bot_names = bot.send(BotNameListRequest).await.unwrap(); TmtuTemplate { bot_names, @@ -23,10 +23,10 @@ pub async fn index(bot: web::Data>) -> Result>, + bot: web::Data>, name: String, ) -> Result { - let bot_names = bot.send(BotNameListRequest).await.unwrap().unwrap(); + let bot_names = bot.send(BotNameListRequest).await.unwrap(); if let Some(bot) = bot.send(BotDataRequest(name)).await.unwrap() { TmtuTemplate { @@ -35,7 +35,6 @@ pub async fn get_bot( } .into_response() } else { - // TODO to 404 or not to 404 Ok(HttpResponse::Found().header(header::LOCATION, "/").finish()) } } -- cgit v1.2.3-70-g09d2