diff options
| author | unwox <me@unwox.com> | 2024-10-09 16:16:23 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2024-10-09 16:16:23 +0600 |
| commit | b352ba53b25190efa811cdbf99509a38bab7d650 (patch) | |
| tree | 8b23ba98fd06ae36c3177946be8b32fc1b81dffb /worker.go | |
| parent | f91e38cc2da4758f42ca8ad14b4a9e0ba2b19c82 (diff) | |
allow to pass an array of query values to lua
Diffstat (limited to 'worker.go')
| -rw-r--r-- | worker.go | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -99,6 +99,13 @@ func (w *Worker) Start(argv []string, module map[string]any) error { // Listen starts a goroutine listening/handling HTTP requests from the queue. func (w *Worker) Listen(queue chan any) { + stringListToAny := func(slice []string) []any { + res := []any{} + for _, v := range slice { + res = append(res, v) + } + return res + } handle := func() { defer w.lua.RestoreStackFunc()() r := <- queue @@ -130,7 +137,11 @@ func (w *Worker) Listen(queue chan any) { flatQr := make(map[string]any) qr := r.request.URL.Query() for k := range qr { - flatQr[k] = qr.Get(k) + if len(qr[k]) > 1 { + flatQr[k] = stringListToAny(qr[k]) + } else { + flatQr[k] = qr.Get(k) + } } res["query"] = flatQr |
