From c80746bf56651e4824b5a1fed18cad349f2b0dff Mon Sep 17 00:00:00 2001 From: Denis Makogon Date: Thu, 22 Jun 2017 18:23:31 +0300 Subject: [PATCH] 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 --- api/server/call_list.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/server/call_list.go b/api/server/call_list.go index 30f3023a0..2fc955547 100644 --- a/api/server/call_list.go +++ b/api/server/call_list.go @@ -17,11 +17,23 @@ func (s *Server) handleCallList(c *gin.Context) { c.JSON(http.StatusBadRequest, models.ErrRoutesValidationMissingAppName) return } + + _, err := s.Datastore.GetApp(c, appName) + if err != nil { + c.JSON(http.StatusNotFound, models.ErrAppsNotFound) + return + } + appRoute, ok := c.MustGet(api.Path).(string) if ok && appRoute == "" { c.JSON(http.StatusBadRequest, models.ErrRoutesValidationMissingPath) 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}