mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
refactor
This commit is contained in:
30
api/server/routes_list.go
Normal file
30
api/server/routes_list.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/iron-io/functions/api/models"
|
||||
)
|
||||
|
||||
func handleRouteList(c *gin.Context) {
|
||||
log := c.MustGet("log").(logrus.FieldLogger)
|
||||
|
||||
appName := c.Param("app")
|
||||
|
||||
filter := &models.RouteFilter{
|
||||
AppName: appName,
|
||||
}
|
||||
|
||||
routes, err := Api.Datastore.GetRoutes(filter)
|
||||
if err != nil {
|
||||
log.WithError(err).Error(models.ErrRoutesGet)
|
||||
c.JSON(http.StatusInternalServerError, simpleError(models.ErrRoutesGet))
|
||||
return
|
||||
}
|
||||
|
||||
log.WithFields(logrus.Fields{"routes": routes}).Debug("Got routes")
|
||||
|
||||
c.JSON(http.StatusOK, &models.RoutesWrapper{Routes: routes})
|
||||
}
|
||||
Reference in New Issue
Block a user