mirror of
https://github.com/harness/drone.git
synced 2025-05-19 10:29:55 +08:00
31 lines
903 B
Go
31 lines
903 B
Go
// 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 user
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/drone/drone/handler/api/render"
|
|
"github.com/drone/drone/handler/api/request"
|
|
"github.com/drone/drone/logger"
|
|
"github.com/drone/drone/core"
|
|
)
|
|
|
|
// HandleRecent returns an http.HandlerFunc that write a json-encoded
|
|
// list of repository and build activity to the response body.
|
|
func HandleRecent(repos core.RepositoryStore) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
viewer, _ := request.UserFrom(r.Context())
|
|
list, err := repos.ListRecent(r.Context(), viewer.ID)
|
|
if err != nil {
|
|
render.InternalError(w, err)
|
|
logger.FromRequest(r).WithError(err).
|
|
Warnln("api: cannot list repositories")
|
|
} else {
|
|
render.JSON(w, list, 200)
|
|
}
|
|
}
|
|
}
|