diff options
Diffstat (limited to 'worker.go')
| -rw-r--r-- | worker.go | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -40,6 +40,7 @@ type Worker struct { routes map[string]LuaRef started bool mu sync.Mutex + repl *LuaRef } // NewWorker creates a new instance of Worker type. @@ -167,10 +168,16 @@ func (w *Worker) Listen(queue chan *HTTPRequest) { err = l.PCall(1, 3, -3) if err != nil { + var body string + if debug { + body = err.Error() + } else { + body = "server error" + } r.result <- &HTTPResponse{ Code: 500, Headers: make(map[string]string), - Body: "server error", + Body: body, } log.Println("could not process request:\n" + err.Error()) return @@ -234,7 +241,11 @@ outer: func (w *Worker) Eval(code string) error { w.mu.Lock() defer w.mu.Unlock() - defer w.lua.RestoreStackFunc()() + if w.repl != nil { + w.lua.PushFromRef(*w.repl) + w.lua.PushString(code) + return w.lua.PCall(1, 0, 0) + } return w.lua.LoadString(code) } |
