mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 09:37:02 +00:00
lua: Preload gluahttp module (#328)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package luahost
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/cjoudrey/gluahttp"
|
||||
lua "github.com/yuin/gopher-lua"
|
||||
)
|
||||
|
||||
@@ -24,6 +26,9 @@ func newStatePool(funcProto *lua.FunctionProto) *statePool {
|
||||
func (lp *statePool) newState() (*lua.LState, error) {
|
||||
ls := lua.NewState()
|
||||
|
||||
// Load supplemental native modules.
|
||||
ls.PreloadModule("http", gluahttp.NewHttpModule(&http.Client{}).Loader)
|
||||
|
||||
// Setup channels.
|
||||
for name, ch := range lp.channels {
|
||||
ls.SetGlobal(name, lua.LChannel(ch))
|
||||
|
||||
Reference in New Issue
Block a user