standard route response

This commit is contained in:
Pedro Nasser
2016-08-30 13:42:55 -03:00
parent 662216f7f1
commit 7b230232b8
9 changed files with 16 additions and 16 deletions

View File

@@ -56,5 +56,5 @@ func handleAppCreate(c *gin.Context) {
return return
} }
c.JSON(http.StatusCreated, appResponse{"App successfully created", wapp}) c.JSON(http.StatusCreated, appResponse{"App successfully created", wapp.App})
} }

View File

@@ -29,5 +29,5 @@ func handleAppGet(c *gin.Context) {
return return
} }
c.JSON(http.StatusOK, &models.AppWrapper{app}) c.JSON(http.StatusOK, appResponse{"Successfully loaded app", app})
} }

View File

@@ -23,5 +23,5 @@ func handleAppList(c *gin.Context) {
return return
} }
c.JSON(http.StatusOK, &models.AppsWrapper{apps}) c.JSON(http.StatusOK, appsResponse{"Successfully listed applications", apps})
} }

View File

@@ -39,5 +39,5 @@ func handleAppUpdate(c *gin.Context) {
wapp.App = app wapp.App = app
// Nothing to update right now in apps // Nothing to update right now in apps
c.JSON(http.StatusOK, appResponse{"App successfully updated", wapp}) c.JSON(http.StatusOK, appResponse{"App successfully updated", wapp.App})
} }

View File

@@ -17,23 +17,23 @@ import (
) )
type appResponse struct { type appResponse struct {
Message string Message string `json:"message"`
App models.AppWrapper App *models.App `json:"app"`
} }
type appsResponse struct { type appsResponse struct {
Message string Message string `json:"message"`
Apps models.AppsWrapper Apps models.Apps `json:"apps"`
} }
type routeResponse struct { type routeResponse struct {
Message string Message string `json:"message"`
Route models.RouteWrapper Route *models.Route `json:"route"`
} }
type routesResponse struct { type routesResponse struct {
Message string Message string `json:"message"`
Routes models.RoutesWrapper Routes models.Routes `json:"routes"`
} }
func testRouter() *gin.Engine { func testRouter() *gin.Engine {

View File

@@ -75,5 +75,5 @@ func handleRouteCreate(c *gin.Context) {
return return
} }
c.JSON(http.StatusCreated, routeResponse{"Route successfully created", wroute}) c.JSON(http.StatusCreated, routeResponse{"Route successfully created", wroute.Route})
} }

View File

@@ -33,5 +33,5 @@ func handleRouteGet(c *gin.Context) {
log.WithFields(logrus.Fields{"route": route}).Debug("Got route") log.WithFields(logrus.Fields{"route": route}).Debug("Got route")
c.JSON(http.StatusOK, &models.RouteWrapper{route}) c.JSON(http.StatusOK, routeResponse{"Successfully loaded route", route})
} }

View File

@@ -37,5 +37,5 @@ func handleRouteList(c *gin.Context) {
log.WithFields(logrus.Fields{"routes": routes}).Debug("Got routes") log.WithFields(logrus.Fields{"routes": routes}).Debug("Got routes")
c.JSON(http.StatusOK, &models.RoutesWrapper{Routes: routes}) c.JSON(http.StatusOK, routesResponse{"Sucessfully listed routes", routes})
} }

View File

@@ -45,5 +45,5 @@ func handleRouteUpdate(c *gin.Context) {
return return
} }
c.JSON(http.StatusOK, routeResponse{"Route successfully updated", wroute}) c.JSON(http.StatusOK, routeResponse{"Route successfully updated", wroute.Route})
} }