mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 10:13:01 +00:00
28 lines
549 B
Go
28 lines
549 B
Go
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()
|
|
}
|
|
}
|
|
}
|