github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/api/server/routes_get.go (about)

     1  package server
     2  
     3  import (
     4  	"context"
     5  	"net/http"
     6  	"path"
     7  
     8  	"github.com/gin-gonic/gin"
     9  	"github.com/iron-io/functions/api"
    10  )
    11  
    12  func (s *Server) handleRouteGet(c *gin.Context) {
    13  	ctx := c.MustGet("ctx").(context.Context)
    14  
    15  	appName := c.MustGet(api.AppName).(string)
    16  	routePath := path.Clean(c.MustGet(api.Path).(string))
    17  
    18  	route, err := s.Datastore.GetRoute(ctx, appName, routePath)
    19  	if err != nil {
    20  		handleErrorResponse(c, err)
    21  		return
    22  	}
    23  
    24  	c.JSON(http.StatusOK, routeResponse{"Successfully loaded route", route})
    25  }