修改中间件结构

This commit is contained in:
zhangwenjian committed 2020-04-13 00:11:47 +08:00
1 parent 531cc6926d
commit 4106f023d0
7 files changed
+341

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
package middleware
import (
"github.com/gin-gonic/gin"
"go-admin/config"
"net/http"
)
func DemoEvn() gin.HandlerFunc {
return func(c *gin.Context) {
if config.ApplicationConfig.Env == "demo" {
method := c.Request.Method
if method == "GET" || method == "OPTIONS" || c.Request.RequestURI == "/login" || c.Request.RequestURI == "/api/v1/logout" {
c.Next()
} else {
c.JSON(http.StatusOK, gin.H{
"code": 500,
"msg": config.ApplicationConfig.EnvMsg,
})
c.Abort()
return
}
} else {
c.Next()
}
}
}