(lis net.Listener, c *config.Config)
| 31 | ) |
| 32 | |
| 33 | func setupServer(lis net.Listener, c *config.Config) { |
| 34 | mux := http.NewServeMux() |
| 35 | mux.Handle("/config", handler.Config(c)) |
| 36 | mux.Handle("/debug/vars", expvar.Handler()) |
| 37 | |
| 38 | mux.HandleFunc("/debug/pprof/", pprof.Index) |
| 39 | mux.HandleFunc("/debug/pprof/profile", pprof.Profile) |
| 40 | mux.HandleFunc("/debug/freemem", func(writer http.ResponseWriter, request *http.Request) { |
| 41 | debug.FreeOSMemory() |
| 42 | }) |
| 43 | |
| 44 | srv := &http.Server{ |
| 45 | Handler: mux, |
| 46 | } |
| 47 | |
| 48 | go func() { |
| 49 | if err := srv.Serve(lis); err != nil && err != http.ErrServerClosed { |
| 50 | if strings.Contains(err.Error(), "use of closed network connection") { |
| 51 | return |
| 52 | } |
| 53 | log.Errorf("unable to bind the API server: %v", err) |
| 54 | } |
| 55 | }() |
| 56 | } |
no test coverage detected