// Copyright 2019 Drone.IO Inc. All rights reserved. // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. package users import ( "net/http" "github.com/drone/drone/handler/api/render" "github.com/drone/drone/logger" "github.com/drone/drone/core" ) // HandleList returns an http.HandlerFunc that writes a json-encoded // list of all registered system users to the response body. func HandleList(users core.UserStore) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { users, err := users.List(r.Context()) if err != nil { render.InternalError(w, err) logger.FromRequest(r).WithError(err). Warnln("api: cannot list users") } else { render.JSON(w, users, 200) } } }