pkg/http/rest/handler.go

38 lines
917 B
Go
Raw Permalink Normal View History

2024-12-28 12:26:36 +00:00
package rest
2023-04-09 15:44:24 +00:00
import (
"net/http"
"net/http/pprof"
)
// ProfilerHandler
func ProfilerHandler() http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
// 性能监控
// https://github.com/thanos-io/thanos/blob/main/pkg/server/http/http.go#L118
2024-12-28 12:29:33 +00:00
// mux.Handle("/debug/fgprof", fgprof.Handler())
2023-04-09 15:44:24 +00:00
return mux
}
// HealthyHandler Healthz 接口
func HealthzHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
}
// HealthyHandler 健康检查
func HealthyHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
}
// ReadyHandler 健康检查
func ReadyHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
}