// 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" "github.com/go-chi/chi" ) // HandleFind returns an http.HandlerFunc that writes json-encoded // user account information to the the response body. func HandleFind(users core.UserStore) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { login := chi.URLParam(r, "user") user, err := users.FindLogin(r.Context(), login) if err != nil { render.NotFound(w, err) logger.FromRequest(r).Debugln("api: cannot find user") } else { render.JSON(w, user, 200) } } }