mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Merge pull request #85 from pedronasser/standard-route-response
Standard route response
This commit is contained in:
@@ -56,5 +56,5 @@ func handleAppCreate(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, appResponse{"App successfully created", wapp})
|
||||
c.JSON(http.StatusCreated, appResponse{"App successfully created", wapp.App})
|
||||
}
|
||||
|
||||
@@ -29,5 +29,5 @@ func handleAppGet(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, &models.AppWrapper{app})
|
||||
c.JSON(http.StatusOK, appResponse{"Successfully loaded app", app})
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ func handleAppList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, &models.AppsWrapper{apps})
|
||||
c.JSON(http.StatusOK, appsResponse{"Successfully listed applications", apps})
|
||||
}
|
||||
|
||||
@@ -39,5 +39,5 @@ func handleAppUpdate(c *gin.Context) {
|
||||
wapp.App = app
|
||||
|
||||
// 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})
|
||||
}
|
||||
|
||||
@@ -17,23 +17,23 @@ import (
|
||||
)
|
||||
|
||||
type appResponse struct {
|
||||
Message string
|
||||
App models.AppWrapper
|
||||
Message string `json:"message"`
|
||||
App *models.App `json:"app"`
|
||||
}
|
||||
|
||||
type appsResponse struct {
|
||||
Message string
|
||||
Apps models.AppsWrapper
|
||||
Message string `json:"message"`
|
||||
Apps models.Apps `json:"apps"`
|
||||
}
|
||||
|
||||
type routeResponse struct {
|
||||
Message string
|
||||
Route models.RouteWrapper
|
||||
Message string `json:"message"`
|
||||
Route *models.Route `json:"route"`
|
||||
}
|
||||
|
||||
type routesResponse struct {
|
||||
Message string
|
||||
Routes models.RoutesWrapper
|
||||
Message string `json:"message"`
|
||||
Routes models.Routes `json:"routes"`
|
||||
}
|
||||
|
||||
func testRouter() *gin.Engine {
|
||||
|
||||
@@ -75,5 +75,5 @@ func handleRouteCreate(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, routeResponse{"Route successfully created", wroute})
|
||||
c.JSON(http.StatusCreated, routeResponse{"Route successfully created", wroute.Route})
|
||||
}
|
||||
|
||||
@@ -33,5 +33,5 @@ func handleRouteGet(c *gin.Context) {
|
||||
|
||||
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})
|
||||
}
|
||||
|
||||
@@ -37,5 +37,5 @@ func handleRouteList(c *gin.Context) {
|
||||
|
||||
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})
|
||||
}
|
||||
|
||||
@@ -45,5 +45,5 @@ func handleRouteUpdate(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, routeResponse{"Route successfully updated", wroute})
|
||||
c.JSON(http.StatusOK, routeResponse{"Route successfully updated", wroute.Route})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user