Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Get ->MustGet
Browse files Browse the repository at this point in the history
  • Loading branch information
YamiOdymel committed Feb 23, 2022
1 parent c60101b commit 9ab7585
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func main() {

r.GET("/hello", func(c *gin.Context) {
var data Data
// ι€ιŽ ginrs.Get 取得 JWT 資料。
ginrs.Get(c, &data)
// ι€ιŽ ginrs.MustGet 取得 JWT 資料。
ginrs.MustGet(c, &data)
fmt.Println(v.Username)
})
}
Expand Down
4 changes: 2 additions & 2 deletions ginrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func Middleware() func(*gin.Context) {
}
}

// Get gets the Token from the *gin.Context, type cast is required.
func Get(c *gin.Context, dest interface{}) {
// MustGet gets the Token from the *gin.Context, type cast is required.
func MustGet(c *gin.Context, dest interface{}) {
v, _ := c.MustGet(KeyToken).(map[string]interface{})
b, _ := json.Marshal(v)
json.Unmarshal(b, &dest)
Expand Down

0 comments on commit 9ab7585

Please sign in to comment.