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

Method GetUserOnlineStat

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

Source from the content-addressed store, hash-verified

27}
28
29func (s *Service) GetUserOnlineStat(w http.ResponseWriter, r *http.Request) {
30 var request common.StatRequest
31 if err := common.ReadProtoBody(r.Body, &request); err != nil {
32 http.Error(w, err.Error(), http.StatusBadRequest)
33 return
34 }
35
36 stats, err := s.Backend().GetUserOnlineStats(r.Context(), request.GetName())
37 if err != nil {
38 err = common.InterceptNotFound(err)
39 st, _ := status.FromError(err)
40 httpCode := common.GrpcCodeToHTTP(st.Code())
41 http.Error(w, err.Error(), httpCode)
42 return
43 }
44
45 common.SendProtoResponse(w, stats)
46}
47
48func (s *Service) GetUserOnlineIpListStats(w http.ResponseWriter, r *http.Request) {
49 var request common.StatRequest

Callers

nothing calls this directly

Implementers 1

Controllercontroller/controller.go

Calls 8

GetNameMethod · 0.95
ReadProtoBodyFunction · 0.92
InterceptNotFoundFunction · 0.92
GrpcCodeToHTTPFunction · 0.92
SendProtoResponseFunction · 0.92
ErrorMethod · 0.80
BackendMethod · 0.80
GetUserOnlineStatsMethod · 0.65

Tested by

no test coverage detected