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

Method SyncUsers

controller/rest/user.go:54–80  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

52}
53
54func (s *Service) SyncUsers(w http.ResponseWriter, r *http.Request) {
55 body, err := io.ReadAll(r.Body)
56 if err != nil {
57 http.Error(w, "Failed to read request body", http.StatusBadRequest)
58 return
59 }
60 defer r.Body.Close()
61
62 users := &common.Users{}
63 if err = proto.Unmarshal(body, users); err != nil {
64 http.Error(w, "Failed to decode user", http.StatusBadRequest)
65 return
66 }
67
68 if err = s.Backend().SyncUsers(r.Context(), users.GetUsers()); err != nil {
69 http.Error(w, err.Error(), http.StatusInternalServerError)
70 return
71 }
72
73 response, _ := proto.Marshal(&common.Empty{})
74
75 w.Header().Set("Content-Type", "application/x-protobuf")
76 if _, err = w.Write(response); err != nil {
77 http.Error(w, "Failed to write response", http.StatusInternalServerError)
78 return
79 }
80}
81
82func (s *Service) SyncUsersChunked(w http.ResponseWriter, r *http.Request) {
83 reader := bufio.NewReader(r.Body)

Callers

nothing calls this directly

Implementers 1

Controllercontroller/controller.go

Calls 5

GetUsersMethod · 0.95
ErrorMethod · 0.80
BackendMethod · 0.80
CloseMethod · 0.65
SyncUsersMethod · 0.65

Tested by

no test coverage detected