mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
35 lines
894 B
Go
35 lines
894 B
Go
package v2
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/formancehq/go-libs/v3/api"
|
|
"github.com/formancehq/payments/internal/api/backend"
|
|
"github.com/formancehq/payments/internal/models"
|
|
"github.com/formancehq/payments/internal/otel"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
)
|
|
|
|
func connectorsReset(backend backend.Backend) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
ctx, span := otel.Tracer().Start(r.Context(), "v2_connectorsReset")
|
|
defer span.End()
|
|
|
|
span.SetAttributes(attribute.String("connectorID", connectorID(r)))
|
|
connectorID, err := models.ConnectorIDFromString(connectorID(r))
|
|
if err != nil {
|
|
otel.RecordError(span, err)
|
|
api.BadRequest(w, ErrInvalidID, err)
|
|
return
|
|
}
|
|
|
|
if _, err := backend.ConnectorsReset(ctx, connectorID); err != nil {
|
|
otel.RecordError(span, err)
|
|
handleServiceErrors(w, r, err)
|
|
return
|
|
}
|
|
|
|
api.NoContent(w)
|
|
}
|
|
}
|