mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
* Extend extension mechanism to support per-route API extensions * Tidy up comment * Remove print statement * Minor improvement to README * Avoid calling c.Request.Context() twice
24 lines
489 B
Go
24 lines
489 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"path"
|
|
|
|
"github.com/fnproject/fn/api"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (s *Server) handleRouteGet(c *gin.Context) {
|
|
ctx := c.Request.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})
|
|
}
|