Skip to content

Commit

Permalink
example notes for authorization (gin-gonic#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
JodeZer authored Dec 26, 2020
1 parent 440d241 commit e0a5fb8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ func setupRouter() *gin.Engine {
"manu": "123", // user:manu password:123
}))

/* example curl for /admin with basicauth header
Zm9vOmJhcg== is base64("foo:bar")
curl -X POST \
http://localhost:8080/admin \
-H 'authorization: Basic Zm9vOmJhcg==' \
-H 'content-type: application/json' \
-d '{"value":"bar"}'
*/
authorized.POST("admin", func(c *gin.Context) {
user := c.MustGet(gin.AuthUserKey).(string)

Expand Down

0 comments on commit e0a5fb8

Please sign in to comment.