示例#1
0
//GetTagV1Handler is
func GetTagV1Handler(ctx *macaron.Context) (int, []byte) {
	//TODO: If standalone == true, Dockyard will check HEADER Authorization; if standalone == false, Dockyard will check HEADER TOEKN.
	namespace := ctx.Params(":namespace")
	repository := ctx.Params(":repository")

	r := new(models.DockerV1)
	if tags, err := r.GetTags(namespace, repository); err != nil {
		log.Errorf("[%s] get repository tags data error: %s", ctx.Req.RequestURI, err.Error())

		result, _ := json.Marshal(map[string]string{"Error": "Get Repository Tags Error"})
		return http.StatusBadRequest, result
	} else {
		result, _ := json.Marshal(tags)
		ctx.Resp.Header().Set("Content-Length", fmt.Sprint(len(result)))

		return http.StatusOK, result
	}
}