This commit is contained in:
2026-02-24 15:59:26 -05:00
parent ebd14a1b36
commit 1dd76cf1d2
24 changed files with 338 additions and 227 deletions

View File

@@ -14,14 +14,7 @@ type reqData struct {
params map[string]string
}
type DeclarativeSets struct {
protos struct {
http bool
gemini bool
}
}
func render(luapath string, requestData reqData, setBuffer *DeclarativeSets) ([]byte, error) {
func render(luapath string, requestData reqData, protocol Protocols) ([]byte, error) {
L := lua.NewState()
defer L.Close()
@@ -74,6 +67,36 @@ func render(luapath string, requestData reqData, setBuffer *DeclarativeSets) ([]
panic("fes module did not return table")
}
if err := L.CallByParam(lua.P{
Fn: L.GetGlobal("require"),
NRet: 1,
Protect: true,
}, lua.LString("lib.std")); err != nil {
panic(err)
}
stdMod := L.Get(-1)
L.Pop(1)
stdTbl, ok := stdMod.(*lua.LTable)
if !ok {
panic("lib.std did not return table")
}
proto := func() string {
switch protocol {
case HTTP:
return "http"
case GEMINI:
return "gemini"
default:
return "http"
}
}()
stdTbl.RawSetString("proto", lua.LString(proto))
tbl.RawSetString("std", stdTbl)
bus := L.NewTable()
bus.RawSetString("url", lua.LString(requestData.path))