add demo model

This commit is contained in:
liuzhihang1
2025-02-19 16:34:10 +08:00
parent 23cd6e09dd
commit d3e86624f2
2 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package middle
import (
"net/http"
"slices"
"github.com/gin-gonic/gin"
)
// 演示模式
func DemoMiddle() func(c *gin.Context) {
return func(ctx *gin.Context) {
whiteListUri := []string{
"/api/user/login",
"/api/log",
}
if ctx.Request.Method == http.MethodGet || slices.Contains(whiteListUri, ctx.Request.URL.String()) {
ctx.Next()
} else {
ctx.Abort()
}
}
}