Example #1
0
// RegistryDelete removes a specific registry.
func RegistryDelete(c *gin.Context) {
	record := session.Registry(c)

	err := store.DeleteRegistry(
		c,
		record,
	)

	if err != nil {
		logrus.Warnf("Failed to delete registry. %s", err)

		c.JSON(
			http.StatusBadRequest,
			gin.H{
				"status":  http.StatusBadRequest,
				"message": "Failed to delete registry",
			},
		)

		c.Abort()
		return
	}

	c.JSON(
		http.StatusOK,
		gin.H{
			"status":  http.StatusOK,
			"message": "Successfully deleted registry",
		},
	)
}
Example #2
0
// RegistryShow retrieves a specific registry.
func RegistryShow(c *gin.Context) {
	record := session.Registry(c)

	c.JSON(
		http.StatusOK,
		record,
	)
}
Example #3
0
// RegistryUpdate updates an existing registry.
func RegistryUpdate(c *gin.Context) {
	record := session.Registry(c)

	if err := c.BindJSON(&record); err != nil {
		logrus.Warnf("Failed to bind registry data. %s", err)

		c.JSON(
			http.StatusPreconditionFailed,
			gin.H{
				"status":  http.StatusPreconditionFailed,
				"message": "Failed to bind registry data",
			},
		)

		c.Abort()
		return
	}

	err := store.UpdateRegistry(
		c,
		record,
	)

	if err != nil {
		logrus.Warnf("Failed to update registry. %s", err)

		c.JSON(
			http.StatusBadRequest,
			gin.H{
				"status":  http.StatusBadRequest,
				"message": err.Error(),
			},
		)

		c.Abort()
		return
	}

	c.JSON(
		http.StatusOK,
		record,
	)
}