github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/api/server/routes_delete.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) handleRouteDelete(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  	if err := s.Datastore.RemoveRoute(ctx, appName, routePath); err != nil {
    19  		handleErrorResponse(c, err)
    20  		return
    21  	}
    22  
    23  	s.cachedelete(appName, routePath)
    24  	c.JSON(http.StatusOK, gin.H{"message": "Route deleted"})
    25  }