mirror of
https://github.com/hanzo-fi/webhooks.git
synced 2026-10-30 20:32:55 +00:00
27 lines
891 B
Go
27 lines
891 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/hanzo-fi/go-libs/v2/logging"
|
|
"github.com/hanzo-fi/webhooks/pkg/server/apierrors"
|
|
"github.com/hanzo-fi/webhooks/pkg/storage"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func (h *serverHandler) deleteOneConfigHandle(w http.ResponseWriter, r *http.Request) {
|
|
id := chi.URLParam(r, PathParamId)
|
|
err := h.store.DeleteOneConfig(r.Context(), id)
|
|
if err == nil {
|
|
logging.FromContext(r.Context()).Debugf("DELETE %s/%s", PathConfigs, id)
|
|
} else if errors.Is(err, storage.ErrConfigNotFound) {
|
|
logging.FromContext(r.Context()).Debugf("DELETE %s/%s: %s", PathConfigs, id, storage.ErrConfigNotFound)
|
|
apierrors.ResponseError(w, r, apierrors.NewNotFoundError(storage.ErrConfigNotFound.Error()))
|
|
} else {
|
|
logging.FromContext(r.Context()).Errorf("DELETE %s/%s: %s", PathConfigs, id, err)
|
|
apierrors.ResponseError(w, r, err)
|
|
}
|
|
}
|