Files
fn-serverless/api/server/routes_get.go
Pedro Nasser a80fe9c897 Fix datastore error for inexistent app (#493)
* fix datastore error inexistent app

* fix get route error handling

* fix API errors handling and tests
2017-01-26 14:41:18 -08:00

26 lines
515 B
Go

package server
import (
"context"
"net/http"
"path"
"github.com/gin-gonic/gin"
"github.com/iron-io/functions/api"
)
func (s *Server) handleRouteGet(c *gin.Context) {
ctx := c.MustGet("ctx").(context.Context)
appName := c.MustGet(api.AppName).(string)
routePath := path.Clean(c.MustGet(api.Path).(string))
route, err := s.Datastore.GetRoute(ctx, appName, routePath)
if err != nil {
handleErrorResponse(c, err)
return
}
c.JSON(http.StatusOK, routeResponse{"Successfully loaded route", route})
}