demo.go 551 B

1234567891011121314151617181920212223242526
  1. package middleware
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "net/http"
  5. )
  6. func DemoEvn() gin.HandlerFunc {
  7. return func(c *gin.Context) {
  8. method := c.Request.Method
  9. if method == "GET" ||
  10. method == "OPTIONS" ||
  11. c.Request.RequestURI == "/api/v1/login" ||
  12. c.Request.RequestURI == "/api/v1/logout" {
  13. c.Next()
  14. } else {
  15. c.JSON(http.StatusOK, gin.H{
  16. "code": 500,
  17. "msg": "谢谢您的参与,但为了大家更好的体验,所以本次提交就算了吧!\U0001F600\U0001F600\U0001F600",
  18. })
  19. c.Abort()
  20. return
  21. }
  22. }
  23. }