refactor🎨: demo环境中间件

This commit is contained in:
zhangwenjian
2021-06-11 16:05:03 +08:00
parent 40668581b8
commit 325b2cc0a2
+27
View File
@@ -0,0 +1,27 @@
package middleware
import (
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func DemoEvn() gin.HandlerFunc {
return func(c *gin.Context) {
method := c.Request.Method
if method == "GET" ||
method == "OPTIONS" ||
strings.Contains(c.Request.RequestURI, "/login") ||
strings.Contains(c.Request.RequestURI, "/logout") {
c.Next()
} else {
c.JSON(http.StatusOK, gin.H{
"code": 500,
"msg": "谢谢您的参与,但为了大家更好的体验,所以本次提交就算了吧!\U0001F600\U0001F600\U0001F600",
})
c.Abort()
return
}
}
}