Start starts the receiver api server in a goroutine
()
| 48 | |
| 49 | // Start starts the receiver api server in a goroutine |
| 50 | func (api *ReceiveAPI) Start() <-chan error { |
| 51 | api.logger.Infof("Starting receiver api server at address %v", api.ipPortAddr) |
| 52 | |
| 53 | mux := http.NewServeMux() |
| 54 | httpServer := http.Server{ |
| 55 | Addr: api.ipPortAddr, |
| 56 | Handler: mux, |
| 57 | } |
| 58 | |
| 59 | mux.HandleFunc("/receive", api.receive) |
| 60 | errChan := run(api.logger, &httpServer) |
| 61 | return errChan |
| 62 | } |
| 63 | |
| 64 | func (api *ReceiveAPI) receive(w http.ResponseWriter, r *http.Request) { |
| 65 | decoder := json.NewDecoder(r.Body) |