wallet/pkg/rest/account_v1_count.go
Anton Nesterov b19bf34e5f
[init]
2024-08-31 16:54:43 +02:00

42 lines
723 B
Go

package rest
import (
"net/http"
store "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,
})
}