captcha.go 445 B

123456789101112131415161718192021
  1. package handlers
  2. import (
  3. "net/http"
  4. "easydo-echo_win7/services"
  5. "easydo-echo_win7/utils"
  6. "github.com/labstack/echo/v4"
  7. )
  8. // GenerateCaptcha 生成验证码
  9. func generateCaptcha(c echo.Context) error {
  10. // 生成验证码
  11. captcha, err := services.GenerateCaptcha()
  12. if err != nil {
  13. return c.JSON(http.StatusInternalServerError, utils.ErrorResponse("生成验证码失败", err.Error()))
  14. }
  15. return c.JSON(http.StatusOK, captcha)
  16. }