Example #1
0
//AppcPutManifestV1Handler is
func AppcPutManifestV1Handler(ctx *macaron.Context) (int, []byte) {
	namespace := ctx.Params(":namespace")
	repository := ctx.Params(":repository")
	version := ctx.Params(":version")
	aci := ctx.Params(":aci")

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

		result, _ := json.Marshal(map[string]string{"message": "Get Appc Repository Error."})
		return http.StatusBadRequest, result
	}

	data, _ := ctx.Req.Body().Bytes()
	i := new(models.ACIv1)
	if err := i.PutManifest(r.ID, version, aci, string(data)); err != nil {
		log.Errorf("[%s] put ACIV1 manifest error: %s", ctx.Req.RequestURI, err.Error())

		result, _ := json.Marshal(map[string]string{"message": "Put ACI Manifest Error."})
		return http.StatusBadRequest, result
	}

	result, _ := json.Marshal(map[string]string{})
	return http.StatusOK, result
}