mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-13 17:58:00 -07:00
Add JSONP support for monitoring routes
This commit is contained in:
@@ -141,7 +141,12 @@ func (s *Server) HandleConnz(w http.ResponseWriter, r *http.Request) {
|
||||
Errorf("Error marshalling response to /connz request: %v", err)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(b)
|
||||
callback := r.FormValue("callback")
|
||||
if callback != "" {
|
||||
fmt.Fprintf(w, "%s(%s)", callback, b)
|
||||
} else {
|
||||
w.Write(b)
|
||||
}
|
||||
}
|
||||
|
||||
func castToSliceString(input []interface{}) []string {
|
||||
@@ -221,7 +226,12 @@ func (s *Server) HandleRoutez(w http.ResponseWriter, r *http.Request) {
|
||||
Errorf("Error marshalling response to /routez request: %v", err)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(b)
|
||||
callback := r.FormValue("callback")
|
||||
if callback != "" {
|
||||
fmt.Fprintf(w, "%s(%s)", callback, b)
|
||||
} else {
|
||||
w.Write(b)
|
||||
}
|
||||
}
|
||||
|
||||
// HandleStats process HTTP requests for subjects stats.
|
||||
@@ -233,7 +243,12 @@ func (s *Server) HandleSubsz(w http.ResponseWriter, r *http.Request) {
|
||||
Errorf("Error marshalling response to /subscriptionsz request: %v", err)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(b)
|
||||
callback := r.FormValue("callback")
|
||||
if callback != "" {
|
||||
fmt.Fprintf(w, "%s(%s)", callback, b)
|
||||
} else {
|
||||
w.Write(b)
|
||||
}
|
||||
}
|
||||
|
||||
// Varz will output server information on the monitoring port at /varz.
|
||||
@@ -323,7 +338,12 @@ func (s *Server) HandleVarz(w http.ResponseWriter, r *http.Request) {
|
||||
Errorf("Error marshalling response to /varz request: %v", err)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(b)
|
||||
callback := r.FormValue("callback")
|
||||
if callback != "" {
|
||||
fmt.Fprintf(w, "%s(%s)", callback, b)
|
||||
} else {
|
||||
w.Write(b)
|
||||
}
|
||||
}
|
||||
|
||||
// Grab RSS and PCPU
|
||||
|
||||
Reference in New Issue
Block a user