Example #1
0
func bindBucket(w http.ResponseWriter, r render.Render, c martini.Context, params martini.Params, db database.Database) {
	bucket, err := db.GetBucket(params["bucket_id"])
	if bucket == nil {
		api.JsonErrorf(r, http.StatusBadRequest, err.Error())
		return
	}
	c.Map(bucket)

	if err != nil && err.EntityNotFound() {
		api.JsonErrorf(r, http.StatusBadRequest, "Bucket not found")
		return
	}

	if err != nil {
		api.JsonErrorf(r, http.StatusInternalServerError, "Database failure while trying to fetch bucket instance: %s", err.Error())
	}
}
Example #2
0
func bindArtifact(w http.ResponseWriter, r render.Render, c martini.Context, params martini.Params, bucket *model.Bucket, db database.Database) {
	if bucket == nil {
		// XXX I don't know why we do this.
		var artifact *model.Artifact
		artifact = nil
		c.Map(artifact)
		return
	}

	artifact := api.GetArtifact(bucket, params["artifact_name"], db)

	if artifact == nil {
		api.JsonErrorf(r, http.StatusBadRequest, "Artifact not found")
		return
	}

	c.Map(artifact)
}