save
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user