Skip to content

Commit

Permalink
add file cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zcool321 committed Jan 24, 2022
1 parent 35c210a commit 9a28b27
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Change Log 更新说明
------------------------------
## 2022-01-24 v1.5.1
## 2022-01-24 v1.5.2
1. 支持缓存使用文件存储;

## 2022-01-12 v1.5.0
Expand Down
4 changes: 2 additions & 2 deletions gtoken/gtoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func (m *GfToken) AuthPath(ctx context.Context, urlPath string) bool {
}
// 分组拦截,登录接口不拦截
if m.MiddlewareType == MiddlewareTypeGroup {
if gstr.HasSuffix(urlPath, m.LoginPath) ||
gstr.HasSuffix(urlPath, m.LogoutPath) {
if (m.LoginPath != "" && gstr.HasSuffix(urlPath, m.LoginPath)) ||
(m.LogoutPath != "" && gstr.HasSuffix(urlPath, m.LogoutPath)) {
return false
}
}
Expand Down
6 changes: 4 additions & 2 deletions gtoken/gtoken_conts.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gtoken

import "fmt"
import (
"fmt"
)

const (
CacheModeCache = 1
Expand Down Expand Up @@ -47,5 +49,5 @@ func msgLog(msg string, params ...interface{}) string {
if len(params) == 0 {
return DefaultLogPrefix + msg
}
return DefaultLogPrefix + fmt.Sprintf(msg, params)
return DefaultLogPrefix + fmt.Sprintf(msg, params...)
}
14 changes: 14 additions & 0 deletions gtoken/gtoken_msg_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gtoken

import (
"testing"
)

func TestMsg(t *testing.T) {
if msgLog("123") != "[GToken]123" {
t.Error("msg err")
}
if msgLog("123-%s-%d", "123", 44) != "[GToken]123-123-44" {
t.Error("msg sprintf err")
}
}
1 change: 0 additions & 1 deletion gtoken/gtoken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,4 @@ func BenchmarkEncryptDecryptToken(b *testing.B) {
b.Error("error:", "token decrypt uuid error")
}
}

}

0 comments on commit 9a28b27

Please sign in to comment.