Ejemplo n.º 1
0
func (this *RepoAPIV1Controller) GetRepositoryImages() {
	namespace := string(this.Ctx.Input.Param(":namespace"))
	repository := string(this.Ctx.Input.Param(":repo_name"))

	repo := new(models.Repository)

	if has, _, err := repo.Has(namespace, repository); err != nil {
		this.JSONOut(http.StatusBadRequest, "Read repository json error", nil)
		return
	} else if has == false {
		this.JSONOut(http.StatusBadRequest, "Read repository no found", nil)
		return
	}

	repo.Download += 1

	if err := repo.Save(); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
	}

	memo, _ := json.Marshal(this.Ctx.Input.Header)
	repo.Log(models.ACTION_GET_REPO, models.LEVELINFORMATIONAL, models.TYPE_APIV1, repo.Id, memo)

	this.Ctx.Output.Context.Output.SetStatus(http.StatusOK)
	this.Ctx.Output.Context.Output.Body([]byte(repo.JSON))
	return
}