mirror of https://github.com/portainer/portainer
26 lines
781 B
Go
26 lines
781 B
Go
|
package webhooks
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/portainer/portainer"
|
||
|
httperror "github.com/portainer/portainer/http/error"
|
||
|
"github.com/portainer/portainer/http/request"
|
||
|
"github.com/portainer/portainer/http/response"
|
||
|
)
|
||
|
|
||
|
// 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)
|
||
|
}
|