-
Notifications
You must be signed in to change notification settings - Fork 139
/
init.go
49 lines (38 loc) · 2.89 KB
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package http
import (
"expvar"
"net/http"
"net/http/pprof"
"github.com/dgryski/httputil"
"github.com/go-graphite/carbonapi/cmd/carbonapi/config"
"github.com/go-graphite/carbonapi/util/ctx"
)
func InitHandlers(headersToPass, headersToLog []string) *http.ServeMux {
r := http.NewServeMux()
r.HandleFunc(config.Config.Prefix+"/render/", httputil.TrackConnections(httputil.TimeHandler(enrichContextWithHeaders(headersToPass, headersToLog, ctx.ParseCtx(renderHandler, ctx.HeaderUUIDAPI)), bucketRequestTimes)))
r.HandleFunc(config.Config.Prefix+"/render", httputil.TrackConnections(httputil.TimeHandler(enrichContextWithHeaders(headersToPass, headersToLog, ctx.ParseCtx(renderHandler, ctx.HeaderUUIDAPI)), bucketRequestTimes)))
r.HandleFunc(config.Config.Prefix+"/metrics/find/", httputil.TrackConnections(httputil.TimeHandler(enrichContextWithHeaders(headersToPass, headersToLog, ctx.ParseCtx(findHandler, ctx.HeaderUUIDAPI)), bucketRequestTimes)))
r.HandleFunc(config.Config.Prefix+"/metrics/find", httputil.TrackConnections(httputil.TimeHandler(enrichContextWithHeaders(headersToPass, headersToLog, ctx.ParseCtx(findHandler, ctx.HeaderUUIDAPI)), bucketRequestTimes)))
r.HandleFunc(config.Config.Prefix+"/info/", httputil.TrackConnections(httputil.TimeHandler(enrichContextWithHeaders(headersToPass, headersToLog, ctx.ParseCtx(infoHandler, ctx.HeaderUUIDAPI)), bucketRequestTimes)))
r.HandleFunc(config.Config.Prefix+"/info", httputil.TrackConnections(httputil.TimeHandler(enrichContextWithHeaders(headersToPass, headersToLog, ctx.ParseCtx(infoHandler, ctx.HeaderUUIDAPI)), bucketRequestTimes)))
r.HandleFunc(config.Config.Prefix+"/lb_check", lbcheckHandler)
r.HandleFunc(config.Config.Prefix+"/version", versionHandler)
r.HandleFunc(config.Config.Prefix+"/version/", versionHandler)
r.HandleFunc(config.Config.Prefix+"/functions", enrichContextWithHeaders(headersToPass, headersToLog, functionsHandler))
r.HandleFunc(config.Config.Prefix+"/functions/", enrichContextWithHeaders(headersToPass, headersToLog, functionsHandler))
r.HandleFunc(config.Config.Prefix+"/tags", enrichContextWithHeaders(headersToPass, headersToLog, tagHandler))
r.HandleFunc(config.Config.Prefix+"/tags/", enrichContextWithHeaders(headersToPass, headersToLog, tagHandler))
r.HandleFunc(config.Config.Prefix+"/", enrichContextWithHeaders(headersToPass, headersToLog, usageHandler))
if config.Config.Expvar.Enabled {
if config.Config.Expvar.Listen == "" || config.Config.Expvar.Listen == config.Config.Listen {
r.HandleFunc(config.Config.Prefix+"/debug/vars", expvar.Handler().ServeHTTP)
if config.Config.Expvar.PProfEnabled {
r.HandleFunc(config.Config.Prefix+"/debug/pprof/heap", pprof.Index)
r.HandleFunc(config.Config.Prefix+"/debug/pprof/profile", pprof.Profile)
r.HandleFunc(config.Config.Prefix+"/debug/pprof/symbol", pprof.Symbol)
r.HandleFunc(config.Config.Prefix+"/debug/pprof/trace", pprof.Trace)
}
}
}
return r
}