Files
epusdt/src/controller/base.go
T
line-6000 c69b0d6c0c feat: isolate manual verification RPC usage
- add rpc node purpose support for general/manual_verify/both
- keep scan, WSS and health checks away from manual_verify nodes
- fallback manual hash verification from general RPC to manual_verify RPC
- add public cashier hash submission path and errno responses
- update tests for RPC selection, failover and manual payment flows
2026-05-27 19:36:56 +08:00

52 lines
1.0 KiB
Go

package controller
import (
"github.com/GMWalletApp/epusdt/util/constant"
"github.com/GMWalletApp/epusdt/util/http"
"github.com/gookit/validate"
"github.com/gookit/validate/locales/zhcn"
"github.com/gookit/validate/locales/zhtw"
"github.com/labstack/echo/v4"
"sync"
)
var Ctrl = &BaseController{}
type validatorBase struct {
once sync.Once
validate *validate.Validation
}
type BaseController struct {
http.Resp
Validator validatorBase
Locale string
}
func (c *BaseController) GetLocale(ctx echo.Context) string {
c.Locale = ctx.Request().Header.Get("locale")
return c.Locale
}
func (c *BaseController) RegisterGlobal(ctx echo.Context) {
locale := c.GetLocale(ctx)
switch locale {
case "zh":
zhcn.RegisterGlobal()
case "zh-tw":
zhtw.RegisterGlobal()
default:
zhcn.RegisterGlobal()
}
}
func (c *BaseController) ValidateStruct(ctx echo.Context, i interface{}, scene ...string) error {
c.RegisterGlobal(ctx)
v := validate.Struct(i, scene...)
if v.Validate() {
return nil
} else {
return constant.ParamsMarshalErr
}
}