mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
36 lines
873 B
Go
36 lines
873 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/pkg/domain/models"
|
|
"github.com/hanzo-fi/payments/internal/otel"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
)
|
|
|
|
func accountsGet(backend backend.Backend) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
ctx, span := otel.Tracer().Start(r.Context(), "v3_accountsGet")
|
|
defer span.End()
|
|
|
|
span.SetAttributes(attribute.String("accountID", accountID(r)))
|
|
id, err := models.AccountIDFromString(accountID(r))
|
|
if err != nil {
|
|
otel.RecordError(span, err)
|
|
api.BadRequest(w, ErrInvalidID, err)
|
|
return
|
|
}
|
|
|
|
account, err := backend.AccountsGet(ctx, id)
|
|
if err != nil {
|
|
otel.RecordError(span, err)
|
|
handleServiceErrors(w, r, err)
|
|
return
|
|
}
|
|
|
|
api.Ok(w, account)
|
|
}
|
|
}
|