mirror of
https://github.com/lzh-1625/go_process_manager.git
synced 2025-10-05 16:06:51 +08:00
add demo model
This commit is contained in:
23
internal/app/middle/demo.go
Normal file
23
internal/app/middle/demo.go
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -54,6 +54,7 @@ func routePathInit(r *gin.Engine) {
|
|||||||
apiGroup := r.Group("/api")
|
apiGroup := r.Group("/api")
|
||||||
apiGroup.Use(middle.CheckToken())
|
apiGroup.Use(middle.CheckToken())
|
||||||
apiGroup.Use(middle.PanicMiddle())
|
apiGroup.Use(middle.PanicMiddle())
|
||||||
|
// apiGroup.Use(middle.DemoMiddle())
|
||||||
{
|
{
|
||||||
apiGroup.GET("/ws", middle.OprPermission(constants.OPERATION_TERMINAL), api.WsApi.WebsocketHandle)
|
apiGroup.GET("/ws", middle.OprPermission(constants.OPERATION_TERMINAL), api.WsApi.WebsocketHandle)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user