mirror of
				https://github.com/lzh-1625/go_process_manager.git
				synced 2025-10-31 19:32:43 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			440 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			440 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 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 {
 | |
| 			rErr(ctx, -1, "当前处于演示模式", nil)
 | |
| 			ctx.Abort()
 | |
| 		}
 | |
| 	}
 | |
| }
 | 
