Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler HTTP 处理器
func NewHandler ¶
func NewHandler(service frameCaptcha.Service, config *frameCaptcha.Config) *Handler
NewHandler 创建处理器
func (*Handler) Generate ¶
func (h *Handler) Generate(w http.ResponseWriter, r *http.Request)
Generate godoc @Summary 生成验证码 @Description 生成新的验证码挑战 @Tags captcha @Accept json @Produce json @Param type query string false "验证码类型 (math|image)" default(math) @Success 200 {object} responder.Response @Failure 429 {object} responder.Response @Router /captcha [get]
func (*Handler) Verify ¶
func (h *Handler) Verify(w http.ResponseWriter, r *http.Request)
Verify godoc @Summary 验证验证码 @Description 验证验证码答案 @Tags captcha @Accept json @Produce json @Param request body VerifyRequest true "验证请求" @Success 200 {object} responder.Response @Failure 400 {object} responder.Response @Failure 429 {object} responder.Response @Router /captcha/verify [post]
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module 验证码模块
func (*Module) GetService ¶
func (m *Module) GetService() frameCaptcha.Service
GetService 返回 captcha 服务(用于注入到其他模块)
func (*Module) RegisterPrivateRoutes ¶
RegisterPrivateRoutes 注册私有路由(验证码模块不需要私有路由)
func (*Module) RegisterPublicRoutes ¶
RegisterPublicRoutes 注册公共路由
type VerifyRequest ¶
type VerifyRequest struct {
ID string `json:"id" validate:"required"` // 验证码 ID
Answer string `json:"answer" validate:"required"` // 用户答案
}
VerifyRequest 验证请求