diff options
| author | John Turner <jturner.usa@gmail.com> | 2026-03-06 19:56:32 -0500 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2026-03-06 19:56:32 -0500 |
| commit | 8ebc635c7e659e3a5fdbde48e4e3f66184230c46 (patch) | |
| tree | 00d752615ac50e794447dc58e5cb1cbb1d266d31 /src/handler.rs | |
| parent | fb2c9f640dbb493f7d8de16498bf673a82e019a4 (diff) | |
| download | httpd-8ebc635c7e659e3a5fdbde48e4e3f66184230c46.tar.gz | |
remove rust level handlers, responses will not be generated in lua
Diffstat (limited to 'src/handler.rs')
| -rw-r--r-- | src/handler.rs | 48 |
1 files changed, 0 insertions, 48 deletions
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<Output = Result<Response, Error>>; -} - -#[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<Self> { - match value { - Value::Table(table) => match table.get::<String>("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")), - } - } -} |
