Files
fn-serverless/api/server/routes_delete.go
Reed Allman a8a3e143c7 unexport all data abstractions on Server (#618)
this patch has no behavior changes, changes are:

* server.Datastore() -> server.datastore
* server.MQ -> server.mq
* server.LogDB -> server.logstore
* server.Agent -> server.agent

these were at a minimum not uniform. further, it's probably better to force
configuration through initialization in `server.New` to ensure thread safety
of referencing if someone does want to modify these as well as forcing things
into our initialization path and reducing the surface area of the Server
abstraction.
2017-12-21 13:21:02 -06:00

29 lines
584 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
}
c.JSON(http.StatusOK, gin.H{"message": "Route deleted"})
}