mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
36 lines
921 B
Go
36 lines
921 B
Go
package v3
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/hanzo-fi/go-libs/v5/pkg/transport/api"
|
|
"github.com/hanzo-fi/payments/internal/api/backend"
|
|
"github.com/hanzo-fi/payments/internal/otel"
|
|
"github.com/google/uuid"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
)
|
|
|
|
func paymentServiceUsersGet(backend backend.Backend) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
ctx, span := otel.Tracer().Start(r.Context(), "v3_paymentServiceUsersGet")
|
|
defer span.End()
|
|
|
|
span.SetAttributes(attribute.String("paymentServiceUserID", paymentServiceUserID(r)))
|
|
id, err := uuid.Parse(paymentServiceUserID(r))
|
|
if err != nil {
|
|
otel.RecordError(span, err)
|
|
api.BadRequest(w, ErrInvalidID, err)
|
|
return
|
|
}
|
|
|
|
paymentServiceUser, err := backend.PaymentServiceUsersGet(ctx, id)
|
|
if err != nil {
|
|
otel.RecordError(span, err)
|
|
handleServiceErrors(w, r, err)
|
|
return
|
|
}
|
|
|
|
api.Ok(w, paymentServiceUser)
|
|
}
|
|
}
|