优化结构
This commit is contained in:
@@ -68,7 +68,9 @@ func authenticate(c *gin.Context, auth TokenAuthenticator, allowQueryToken bool)
|
||||
return true
|
||||
}
|
||||
|
||||
func requestToken(c *gin.Context, allowQueryToken bool) string {
|
||||
// RequestToken extracts the authentication token accepted by HTTP handlers.
|
||||
// Query-string tokens are opt-in for WebSocket handshakes only.
|
||||
func RequestToken(c *gin.Context, allowQueryToken bool) string {
|
||||
token := strings.TrimSpace(c.GetHeader("x-token"))
|
||||
if token == "" {
|
||||
authorization := strings.TrimSpace(c.GetHeader("Authorization"))
|
||||
@@ -91,6 +93,10 @@ func requestToken(c *gin.Context, allowQueryToken bool) string {
|
||||
return token
|
||||
}
|
||||
|
||||
func requestToken(c *gin.Context, allowQueryToken bool) string {
|
||||
return RequestToken(c, allowQueryToken)
|
||||
}
|
||||
|
||||
func tokenErrorMessage(err error) string {
|
||||
message := "无法处理此token"
|
||||
switch {
|
||||
|
||||
Reference in New Issue
Block a user