Print random easter egg

This commit is contained in:
Joscha 2024-03-30 16:28:30 +01:00
parent b293408cbc
commit a9ba160c13
15 changed files with 106 additions and 3 deletions

View file

@ -13,8 +13,8 @@ use serde::Deserialize;
use tokio::{net::TcpListener, sync::mpsc};
use crate::drawer::{
CalendarDrawing, CellsDrawing, ChatMessageDrawing, Command, ImageDrawing, PhotoDrawing,
TextDrawing,
CalendarDrawing, CellsDrawing, ChatMessageDrawing, Command, EggDrawing, ImageDrawing,
PhotoDrawing, TextDrawing,
};
use self::{r#static::get_static_file, statuscode::status_code};
@ -29,6 +29,7 @@ pub async fn run(tx: mpsc::Sender<Command>, addr: String) -> anyhow::Result<()>
.route("/calendar", post(post_calendar))
.route("/cells", post(post_cells))
.route("/chat_message", post(post_chat_message))
.route("/egg", post(post_egg))
.route("/image", post(post_image).fallback(get_static_file))
.route("/photo", post(post_photo).fallback(get_static_file))
.route("/text", post(post_text))
@ -97,6 +98,12 @@ async fn post_chat_message(server: State<Server>, request: Form<PostChatMessageF
.await;
}
// /egg
async fn post_egg(server: State<Server>) {
let _ = server.tx.send(Command::draw(EggDrawing)).await;
}
// /image
async fn post_image(server: State<Server>, mut multipart: Multipart) -> somehow::Result<Response> {