diff options
| -rw-r--r-- | main.go | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -8,6 +8,7 @@ import ( func main() { rch := make(chan *WorkerRequest, 4096) + mux := http.NewServeMux() for i := 0; i < 8; i++ { log.Printf("worker %d started\n", i) w := NewWorker(rch) @@ -17,7 +18,10 @@ func main() { } if i == 0 { for _, route := range w.ListRoutes() { - http.HandleFunc( + // we need to copy route otherwise it's going + // to change with every next iteration + route := route + mux.HandleFunc( route, func (wr http.ResponseWriter, r *http.Request) { resCh := w.Request(route, r) @@ -34,6 +38,6 @@ func main() { go w.Listen() defer w.Stop() } - fmt.Println("running") - log.Fatal(http.ListenAndServe("127.0.0.1:3002", nil)) + fmt.Println("luna is running...") + log.Fatal(http.ListenAndServe("127.0.0.1:3002", mux)) } |
