mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
added config to apps and routes
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})
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAppCreate(t *testing.T) {
|
||||
New(&models.Config{}, &datastore.Mock{}, testRunner(t))
|
||||
New(&datastore.Mock{}, testRunner(t))
|
||||
router := testRouter()
|
||||
|
||||
for i, test := range []struct {
|
||||
@@ -52,7 +52,7 @@ func TestAppCreate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAppDelete(t *testing.T) {
|
||||
New(&models.Config{}, &datastore.Mock{}, testRunner(t))
|
||||
New(&datastore.Mock{}, testRunner(t))
|
||||
router := testRouter()
|
||||
|
||||
for i, test := range []struct {
|
||||
@@ -83,7 +83,7 @@ func TestAppDelete(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAppList(t *testing.T) {
|
||||
New(&models.Config{}, &datastore.Mock{}, testRunner(t))
|
||||
New(&datastore.Mock{}, testRunner(t))
|
||||
router := testRouter()
|
||||
|
||||
for i, test := range []struct {
|
||||
@@ -113,7 +113,7 @@ func TestAppList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAppGet(t *testing.T) {
|
||||
New(&models.Config{}, &datastore.Mock{}, testRunner(t))
|
||||
New(&datastore.Mock{}, testRunner(t))
|
||||
router := testRouter()
|
||||
|
||||
for i, test := range []struct {
|
||||
@@ -143,7 +143,7 @@ func TestAppGet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAppUpdate(t *testing.T) {
|
||||
New(&models.Config{}, &datastore.Mock{}, testRunner(t))
|
||||
New(&datastore.Mock{}, testRunner(t))
|
||||
router := testRouter()
|
||||
|
||||
for i, test := range []struct {
|
||||
|
||||
@@ -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})
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ func handleRouteDelete(c *gin.Context) {
|
||||
log := titancommon.Logger(ctx)
|
||||
|
||||
appName := c.Param("app")
|
||||
routeName := c.Param("route")
|
||||
err := Api.Datastore.RemoveRoute(appName, routeName)
|
||||
routePath := c.Param("route")
|
||||
err := Api.Datastore.RemoveRoute(appName, routePath)
|
||||
|
||||
if err != nil {
|
||||
log.WithError(err).Debug(models.ErrRoutesRemoving)
|
||||
|
||||
@@ -16,9 +16,9 @@ func handleRouteGet(c *gin.Context) {
|
||||
log := titancommon.Logger(ctx)
|
||||
|
||||
appName := c.Param("app")
|
||||
routeName := c.Param("route")
|
||||
routePath := c.Param("route")
|
||||
|
||||
route, err := Api.Datastore.GetRoute(appName, routeName)
|
||||
route, err := Api.Datastore.GetRoute(appName, routePath)
|
||||
if err != nil {
|
||||
log.WithError(err).Error(models.ErrRoutesGet)
|
||||
c.JSON(http.StatusInternalServerError, simpleError(models.ErrRoutesGet))
|
||||
|
||||
Reference in New Issue
Block a user