Ejemplo n.º 1
0
//PutImageChecksumV1Handler is put image checksum and payload value in the database.
func PutImageChecksumV1Handler(ctx *macaron.Context) (int, []byte) {
	//TODO: If standalone == true, Dockyard will check HEADER Authorization; if standalone == false, Dockyard will check HEADER TOEKN.
	imageID := ctx.Params(":image")

	checksum := ctx.Req.Header.Get("X-Docker-Checksum")
	payload := ctx.Req.Header.Get("X-Docker-Checksum-Payload")

	image := new(models.DockerImageV1)
	if err := image.PutChecksum(imageID, checksum, payload); err != nil {
		log.Errorf("[%s] Failed to set image checksum and payload error: %s", ctx.Req.RequestURI, err.Error())

		result, _ := json.Marshal(map[string]string{"message": "Put Image Checksum And Payload Data Error"})
		return http.StatusBadRequest, result
	}

	//TODO: Verify the file's checksum.

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