mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
30 lines
619 B
Go
30 lines
619 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"path"
|
|
|
|
"github.com/fnproject/fn/api"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (s *Server) handleRouteDelete(c *gin.Context) {
|
|
ctx := c.Request.Context()
|
|
|
|
appName := c.MustGet(api.AppName).(string)
|
|
routePath := path.Clean(c.MustGet(api.Path).(string))
|
|
|
|
if _, err := s.Datastore.GetRoute(ctx, appName, routePath); err != nil {
|
|
handleErrorResponse(c, err)
|
|
return
|
|
}
|
|
|
|
if err := s.Datastore.RemoveRoute(ctx, appName, routePath); err != nil {
|
|
handleErrorResponse(c, err)
|
|
return
|
|
}
|
|
|
|
s.cachedelete(appName, routePath)
|
|
c.JSON(http.StatusOK, gin.H{"message": "Route deleted"})
|
|
}
|