wallet/pkg/rest/account_v1_count.go
Anton Nesterov 1382da92a3
[init]
2024-08-31 16:46:20 +02:00

41 lines
750 B
Go

package rest
import (
"net/http"
store "git.pspay.io/crypto-stories/custodial/pkg/store"
gin "github.com/gin-gonic/gin"
)
type AccountCountResponse struct {
Count int `json:"count"`
}
// @BasePath /api/v1
//
// AccountCountV1 godoc
//
// @Summary Count accounts
// @Schemes
// @Description Count accounts
// @Tags Account
// @Accept json
// @Security ApiKeyAuth
// @Produce json
// @Success 200 {object} AccountCountResponse
// @Failure 400 {object} ErrorResponse
// @Router /account/count [get]
func AccountCountV1(c *gin.Context) {
count, err := store.CountAccounts(store.Ethereum)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{
"count": count,
})
}