Improve listeners and handlers (#350)

* improve listeners and handlers

* add to route handlers

* separate create/delete/update events

* removed useless interface
This commit is contained in:
Pedro Nasser
2016-11-28 21:00:12 -02:00
committed by C Cirello
parent 308cb25ba2
commit 2c56e7975d
8 changed files with 149 additions and 37 deletions

View File

@@ -28,11 +28,25 @@ func handleAppDelete(c *gin.Context) {
return
}
if err := Api.Datastore.RemoveApp(ctx, appName); err != nil {
err = Api.FireAfterAppDelete(ctx, appName)
if err != nil {
log.WithError(err).Errorln(models.ErrAppsRemoving)
c.JSON(http.StatusInternalServerError, simpleError(err))
return
}
if err = Api.Datastore.RemoveApp(ctx, appName); err != nil {
log.WithError(err).Debug(models.ErrAppsRemoving)
c.JSON(http.StatusInternalServerError, simpleError(models.ErrAppsRemoving))
return
}
err = Api.FireAfterAppDelete(ctx, appName)
if err != nil {
log.WithError(err).Errorln(models.ErrAppsRemoving)
c.JSON(http.StatusInternalServerError, simpleError(err))
return
}
c.JSON(http.StatusOK, gin.H{"message": "App deleted"})
}