MCPcopy Index your code
hub / github.com/PasarGuard/node / GetStats

Method GetStats

controller/rest/stats.go:10–27  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

8)
9
10func (s *Service) GetStats(w http.ResponseWriter, r *http.Request) {
11 var request common.StatRequest
12 if err := common.ReadProtoBody(r.Body, &request); err != nil {
13 http.Error(w, err.Error(), http.StatusBadRequest)
14 return
15 }
16
17 stats, err := s.Backend().GetStats(r.Context(), &request)
18 if err != nil {
19 err = common.InterceptNotFound(err)
20 st, _ := status.FromError(err)
21 httpCode := common.GrpcCodeToHTTP(st.Code())
22 http.Error(w, err.Error(), httpCode)
23 return
24 }
25
26 common.SendProtoResponse(w, stats)
27}
28
29func (s *Service) GetUserOnlineStat(w http.ResponseWriter, r *http.Request) {
30 var request common.StatRequest

Callers

nothing calls this directly

Implementers 1

Controllercontroller/controller.go

Calls 7

ReadProtoBodyFunction · 0.92
InterceptNotFoundFunction · 0.92
GrpcCodeToHTTPFunction · 0.92
SendProtoResponseFunction · 0.92
ErrorMethod · 0.80
BackendMethod · 0.80
GetStatsMethod · 0.65

Tested by

no test coverage detected