aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/main.go b/main.go
index 420ade8..94e11b9 100644
--- a/main.go
+++ b/main.go
@@ -9,6 +9,7 @@ import (
"io/ioutil"
"net/http"
"strings"
+ "time"
"muhq.space/go/wrms/llog"
@@ -36,7 +37,16 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
llog.Debug("Searching for %s", pattern)
- results := wrms.Player.Search(pattern)
+ start := time.Now()
+ resultsChan := wrms.Player.Search(pattern)
+ results := []Song{}
+
+ for result := range resultsChan {
+ results = append(results, result...)
+ }
+
+ llog.Debug("searching for %s took %v", pattern, time.Since(start))
+
data, err := json.Marshal(Event{"search", results})
if err != nil {
llog.Error("Encoding the search result failed with %s", err)