Files
fn-serverless/api/server/routes_get.go
C Cirello fe845e1886 fn: improve UX (#325)
* fn: make UX more consistent with regards to app name position

* fn: improve detection of missing routes

* fn: fix update operations

- No longer delete-than-add for configuration updates
- Path cleaning before most of routes operations
2016-11-22 00:27:48 +01:00

38 lines
870 B
Go

package server
import (
"context"
"net/http"
"path"
"github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin"
"github.com/iron-io/functions/api/models"
"github.com/iron-io/runner/common"
)
func handleRouteGet(c *gin.Context) {
ctx := c.MustGet("ctx").(context.Context)
log := common.Logger(ctx)
appName := c.Param("app")
routePath := path.Clean(c.Param("route"))
route, err := Api.Datastore.GetRoute(appName, routePath)
if err != nil {
log.WithError(err).Error(models.ErrRoutesGet)
c.JSON(http.StatusInternalServerError, simpleError(models.ErrRoutesGet))
return
}
if route == nil {
log.Error(models.ErrRoutesNotFound)
c.JSON(http.StatusNotFound, simpleError(models.ErrRoutesNotFound))
return
}
log.WithFields(logrus.Fields{"route": route}).Debug("Got route")
c.JSON(http.StatusOK, routeResponse{"Successfully loaded route", route})
}