diff options
| author | Jokler <jokler@protonmail.com> | 2020-10-14 00:19:27 +0200 |
|---|---|---|
| committer | Jokler <jokler@protonmail.com> | 2020-10-15 01:45:29 +0200 |
| commit | 4e1c2b9f04073294ecb8402486c20d9c01721598 (patch) | |
| tree | 93fe1d75477ae3d1c8466611a2cedd7bed316aa2 /src/web_server/tmtu.rs | |
| parent | 23671b51b4e207574a63bce820acbf43169e2b6c (diff) | |
| download | pokebot-4e1c2b9f04073294ecb8402486c20d9c01721598.tar.gz pokebot-4e1c2b9f04073294ecb8402486c20d9c01721598.zip | |
Replace channels&locks with actors & log with slog
Diffstat (limited to 'src/web_server/tmtu.rs')
| -rw-r--r-- | src/web_server/tmtu.rs | 17 |
1 files changed, 8 insertions, 9 deletions
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<BotData>, } -pub async fn index(bot: web::Data<Addr<BotExecutor>>) -> Result<HttpResponse, Error> { - let bot_names = bot.send(BotNameListRequest).await.unwrap().unwrap(); +pub async fn index(bot: web::Data<WeakAddress<MasterBot>>) -> Result<HttpResponse, Error> { + let bot_names = bot.send(BotNameListRequest).await.unwrap(); TmtuTemplate { bot_names, @@ -23,10 +23,10 @@ pub async fn index(bot: web::Data<Addr<BotExecutor>>) -> Result<HttpResponse, Er } pub async fn get_bot( - bot: web::Data<Addr<BotExecutor>>, + bot: web::Data<WeakAddress<MasterBot>>, name: String, ) -> Result<HttpResponse, Error> { - 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()) } } |
