missing routers

This commit is contained in:
Pedro Nasser
2016-07-21 16:09:21 -03:00
parent 66fa3d4035
commit 154fd82b68
15 changed files with 379 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
package router
import (
"net/http"
"github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin"
"github.com/iron-io/functions/api/models"
)
func handleAppUpdate(c *gin.Context) {
store := c.MustGet("store").(models.Datastore)
log := c.MustGet("log").(logrus.FieldLogger)
app := &models.App{}
err := c.BindJSON(app)
if err != nil {
log.WithError(err).Debug(models.ErrInvalidJSON)
c.JSON(http.StatusBadRequest, simpleError(models.ErrInvalidJSON))
return
}
app.Name = c.Param("app")
app, err = store.StoreApp(app)
if err != nil {
log.WithError(err).Debug(models.ErrAppsUpdate)
c.JSON(http.StatusInternalServerError, simpleError(models.ErrAppsUpdate))
return
}
c.JSON(http.StatusOK, app)
}