summaryrefslogtreecommitdiff
path: root/worker.go
diff options
context:
space:
mode:
Diffstat (limited to 'worker.go')
-rw-r--r--worker.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/worker.go b/worker.go
index 5ae69c2..e7d76e4 100644
--- a/worker.go
+++ b/worker.go
@@ -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)
}