Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gin中间件直接return和context.Next有什么区别,return是直接返回响应,还是请求依旧往后走,返回的时候也不再进入这个中间件了? #26

Open
graham924 opened this issue Dec 2, 2023 · 0 comments

Comments

@graham924
Copy link

graham924 commented Dec 2, 2023

// JWTAuth jwt认证函数
func JWTAuth() gin.HandlerFunc {
	return func(context *gin.Context) {
		if AlwaysAllowPath.Has(context.Request.URL.Path) {
			return
		}

		if len(context.Request.URL.String()) == 15 && context.Request.URL.String()[0:15] == "/api/user/login" {
			context.Next()
			return
		}
		// 处理验证逻辑
	        
	}
}
@graham924 graham924 changed the title gin中间件直接return和context.Next有什么区别 gin中间件直接return和context.Next有什么区别,return是直接返回响应,还是请求依旧往后走,返回的时候也不再进入这个中间件了? Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant