Esempio n. 1
0
func itemsIndexHandler(db *db.DB) gin.HandlerFunc {
	return func(c *gin.Context) {
		items, err := db.GetItems()

		if err != nil {
			c.JSON(http.StatusInternalServerError, gin.H{
				"items": []string{},
			})
			return
		}

		c.JSON(http.StatusOK, gin.H{
			"items": items,
		})
	}
}