mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
when creating route, create app if not exists
This commit is contained in:
@@ -29,6 +29,21 @@ func handleRouteCreate(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app, err := store.GetApp(route.AppName)
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error(models.ErrAppsGet)
|
||||||
|
c.JSON(http.StatusInternalServerError, simpleError(models.ErrAppsGet))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if app == nil {
|
||||||
|
app, err = store.StoreApp(&models.App{Name: route.AppName})
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error(models.ErrAppsCreate)
|
||||||
|
c.JSON(http.StatusInternalServerError, simpleError(models.ErrAppsCreate))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
route, err = store.StoreRoute(route)
|
route, err = store.StoreRoute(route)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Debug(models.ErrRoutesCreate)
|
log.WithError(err).Debug(models.ErrRoutesCreate)
|
||||||
|
|||||||
Reference in New Issue
Block a user