mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Add app and route validation to calls API handler
This patch adds check for app and route to ensure that they exist before listing calls
This commit is contained in:
@@ -17,11 +17,23 @@ func (s *Server) handleCallList(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, models.ErrRoutesValidationMissingAppName)
|
c.JSON(http.StatusBadRequest, models.ErrRoutesValidationMissingAppName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err := s.Datastore.GetApp(c, appName)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusNotFound, models.ErrAppsNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
appRoute, ok := c.MustGet(api.Path).(string)
|
appRoute, ok := c.MustGet(api.Path).(string)
|
||||||
if ok && appRoute == "" {
|
if ok && appRoute == "" {
|
||||||
c.JSON(http.StatusBadRequest, models.ErrRoutesValidationMissingPath)
|
c.JSON(http.StatusBadRequest, models.ErrRoutesValidationMissingPath)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
_, err = s.Datastore.GetRoute(c, appName, appRoute)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusNotFound, models.ErrRoutesNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
filter := models.CallFilter{AppName:appName, Path:appRoute}
|
filter := models.CallFilter{AppName:appName, Path:appRoute}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user