summaryrefslogtreecommitdiff
path: root/src/handler.rs
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2026-03-05 00:52:03 -0500
committerJohn Turner <jturner.usa@gmail.com>2026-03-05 00:52:03 -0500
commit92e8d4947de614a67fed6709a59365de98705b35 (patch)
tree981213f1ed73c88834f9ec3fe7c9b1b8f3e19211 /src/handler.rs
parent583a62c4a2ac6137134d50f70ff8ad546ac4b2a1 (diff)
downloadhttpd-92e8d4947de614a67fed6709a59365de98705b35.tar.gz
impl Lua handler
Diffstat (limited to 'src/handler.rs')
-rw-r--r--src/handler.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/handler.rs b/src/handler.rs
index 45dc879..eb4d64a 100644
--- a/src/handler.rs
+++ b/src/handler.rs
@@ -1,8 +1,13 @@
+mod lua;
mod staticfile;
use mlua::{FromLua, Value};
-use crate::{handler::staticfile::StaticFile, request::Request, response::Response};
+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>>;
@@ -20,6 +25,7 @@ pub enum Error {
#[derive(Debug)]
pub enum Handler {
StaticFile(StaticFile),
+ Lua(LuaResponse),
}
impl FromLua for Handler {
@@ -30,6 +36,10 @@ impl FromLua for Handler {
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")),