From 8ebc635c7e659e3a5fdbde48e4e3f66184230c46 Mon Sep 17 00:00:00 2001 From: John Turner Date: Fri, 6 Mar 2026 19:56:32 -0500 Subject: remove rust level handlers, responses will not be generated in lua --- src/handler.rs | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 src/handler.rs (limited to 'src/handler.rs') diff --git a/src/handler.rs b/src/handler.rs deleted file mode 100644 index eb4d64a..0000000 --- a/src/handler.rs +++ /dev/null @@ -1,48 +0,0 @@ -mod lua; -mod staticfile; - -use mlua::{FromLua, Value}; - -use crate::{ - handler::{lua::LuaResponse, staticfile::StaticFile}, - request::Request, - response::Response, -}; - -pub trait Handle { - fn handle(self, request: Request) -> impl Future>; -} - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("unsupported method")] - Unsupported, - - #[error("static file handler error: {0}")] - StaticFile(#[from] staticfile::Error), -} - -#[derive(Debug)] -pub enum Handler { - StaticFile(StaticFile), - Lua(LuaResponse), -} - -impl FromLua for Handler { - fn from_lua(value: Value, lua: &mlua::Lua) -> mlua::Result { - match value { - Value::Table(table) => match table.get::("handler")?.as_str() { - "staticfile" => Ok(Self::StaticFile(StaticFile::from_lua( - Value::Table(table.clone()), - lua, - )?)), - "lua" => Ok(Self::Lua(LuaResponse::from_lua( - Value::Table(table.clone()), - lua, - )?)), - _ => Err(mlua::Error::runtime("unknown handler")), - }, - _ => Err(mlua::Error::runtime("expected table")), - } - } -} -- cgit v1.2.3