mirror of
https://github.com/syntrex-lab/gomcp.git
synced 2026-04-26 21:06:21 +02:00
32 lines
872 B
Go
32 lines
872 B
Go
package httpserver
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/pprof"
|
|
)
|
|
|
|
// EnablePprof activates debug profiling endpoints.
|
|
// Should only be enabled in development/staging environments.
|
|
func (s *Server) EnablePprof() {
|
|
s.pprofEnabled = true
|
|
}
|
|
|
|
// handlePprof serves the pprof index page.
|
|
func (s *Server) handlePprof(w http.ResponseWriter, r *http.Request) {
|
|
pprof.Index(w, r)
|
|
}
|
|
|
|
// handlePprofProfile serves CPU profile data.
|
|
func (s *Server) handlePprofProfile(w http.ResponseWriter, r *http.Request) {
|
|
pprof.Profile(w, r)
|
|
}
|
|
|
|
// handlePprofHeap serves heap memory profile data.
|
|
func (s *Server) handlePprofHeap(w http.ResponseWriter, r *http.Request) {
|
|
pprof.Handler("heap").ServeHTTP(w, r)
|
|
}
|
|
|
|
// handlePprofGoroutine serves goroutine stack traces.
|
|
func (s *Server) handlePprofGoroutine(w http.ResponseWriter, r *http.Request) {
|
|
pprof.Handler("goroutine").ServeHTTP(w, r)
|
|
}
|