added config to apps and routes

This commit is contained in:
Pedro Nasser
2016-08-26 23:04:57 -03:00
parent 609d767c3f
commit 2782a6db54
13 changed files with 108 additions and 65 deletions

View File

@@ -14,34 +14,30 @@ func handleAppUpdate(c *gin.Context) {
ctx := c.MustGet("ctx").(context.Context)
log := titancommon.Logger(ctx)
app := &models.App{}
wapp := models.AppWrapper{}
err := c.BindJSON(app)
err := c.BindJSON(&wapp)
if err != nil {
log.WithError(err).Debug(models.ErrInvalidJSON)
c.JSON(http.StatusBadRequest, simpleError(models.ErrInvalidJSON))
return
}
if app == nil {
if wapp.App == nil {
log.Debug(models.ErrAppsMissingNew)
c.JSON(http.StatusBadRequest, simpleError(models.ErrAppsMissingNew))
return
}
if err := app.Validate(); err != nil {
log.Error(err)
c.JSON(http.StatusInternalServerError, simpleError(err))
app, err := Api.Datastore.StoreApp(wapp.App)
if err != nil {
log.WithError(err).Debug(models.ErrAppsCreate)
c.JSON(http.StatusInternalServerError, simpleError(models.ErrAppsCreate))
return
}
// app, err := Api.Datastore.StoreApp(wapp.App)
// if err != nil {
// log.WithError(err).Debug(models.ErrAppsCreate)
// c.JSON(http.StatusInternalServerError, simpleError(models.ErrAppsCreate))
// return
// }
wapp.App = app
// Nothing to update right now in apps
c.JSON(http.StatusOK, simpleError(models.ErrAppsNothingToUpdate))
c.JSON(http.StatusOK, appResponse{"App successfully updated", wapp})
}