From 92e8d4947de614a67fed6709a59365de98705b35 Mon Sep 17 00:00:00 2001 From: John Turner Date: Thu, 5 Mar 2026 00:52:03 -0500 Subject: impl Lua handler --- src/handler.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/handler.rs') 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>; @@ -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")), -- cgit v1.2.3