This commit is contained in:
parent
20cb97f90f
commit
db41f565ca
16
api/http.go
16
api/http.go
@ -235,3 +235,19 @@ func (s *HTTPServer) HandlerAPIUserCreate(w http.ResponseWriter, r *http.Request
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
s.Logger.Infow("Created user.", "req_id", reqID, "remote_addr", r.RemoteAddr, "username", req.Username)
|
||||
}
|
||||
|
||||
func (s *HTTPServer) HandlerAPIUserList(w http.ResponseWriter, r *http.Request) {
|
||||
reqID := middleware.GetReqID(r.Context())
|
||||
|
||||
l, err := s.Users.List()
|
||||
if err != nil {
|
||||
s.Logger.Warnw("Error listing users.", "req_id", reqID, "error", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
if err := encoder.Encode(l); err != nil {
|
||||
s.Logger.Warnw("Error encoding response.", "req_id", "error", err)
|
||||
}
|
||||
}
|
||||
|
@ -18,3 +18,7 @@ type ResponseAPIFilePost struct {
|
||||
ID string `json:"id"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
type ResponseAPIUserList struct {
|
||||
Usernames []string `json:"usernames"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user