mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
standard route response
This commit is contained in:
@@ -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})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user