mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
25 lines
482 B
Go
25 lines
482 B
Go
package api
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
|
|
wallet "github.com/formancehq/wallets/pkg"
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
func (m *MainHandler) getBalanceHandler(w http.ResponseWriter, r *http.Request) {
|
|
balance, err := m.manager.GetBalance(r.Context(), chi.URLParam(r, "walletID"), chi.URLParam(r, "balanceName"))
|
|
if err != nil {
|
|
switch {
|
|
case errors.Is(err, wallet.ErrBalanceNotExists):
|
|
notFound(w)
|
|
default:
|
|
internalError(w, r, err)
|
|
}
|
|
return
|
|
}
|
|
|
|
ok(w, balance)
|
|
}
|