mirror of https://github.com/portainer/portainer
26 lines
764 B
Go
26 lines
764 B
Go
package webhooks
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
"github.com/portainer/libhttp/request"
|
|
"github.com/portainer/libhttp/response"
|
|
"github.com/portainer/portainer/api"
|
|
)
|
|
|
|
// DELETE request on /api/webhook/:serviceID
|
|
func (handler *Handler) webhookDelete(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
id, err := request.RetrieveNumericRouteVariableValue(r, "id")
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid webhook id", err}
|
|
}
|
|
|
|
err = handler.WebhookService.DeleteWebhook(portainer.WebhookID(id))
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to remove the webhook from the database", err}
|
|
}
|
|
|
|
return response.Empty(w)
|
|
}
|