MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / setupServer

Function setupServer

pkg/api/server.go:33–56  ·  view source on GitHub ↗
(lis net.Listener, c *config.Config)

Source from the content-addressed store, hash-verified

31)
32
33func 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}

Callers 1

StartServerFunction · 0.85

Calls 4

ConfigFunction · 0.92
HandleMethod · 0.80
ContainsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected