Skip to content

Commit

Permalink
add only bind post,get
Browse files Browse the repository at this point in the history
  • Loading branch information
zcool321 committed Jan 29, 2022
1 parent 71beb04 commit 2d13a44
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Change Log 更新说明
------------------------------
## 2022-01-29 v1.4.5.1
1. 支持登录,登出仅注册Post,Get等方式

## 2021-08-25 v1.4.5
1. 优化框架日志,常量;
2. 启动加入error错误返回,避免异常继续执行;
Expand Down
17 changes: 15 additions & 2 deletions gtoken/gtoken_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/text/gstr"
)

// Middleware 绑定group
Expand Down Expand Up @@ -33,8 +34,20 @@ func (m *GfToken) Middleware(group *ghttp.RouterGroup) error {
}

group.Middleware(m.authMiddleware)
group.ALL(m.LoginPath, m.Login)
group.ALL(m.LogoutPath, m.Logout)

registerFunc(group, m.LoginPath, m.Login)
registerFunc(group, m.LogoutPath, m.Logout)

return nil
}

// 如果包含请求方式,按照请求方式注册;默认注册所有
func registerFunc(group *ghttp.RouterGroup, pattern string, object interface{}) {
if gstr.Contains(pattern, ":") || gstr.Contains(pattern, "@") {
group.Map(map[string]interface{}{
pattern: object,
})
} else {
group.ALL(pattern, object)
}
}

0 comments on commit 2d13a44

Please sign in to comment.