update example

This commit is contained in:
lyric 2016-09-26 08:59:08 +08:00
parent dedd3b9e02
commit c0b7bb2ca5
2 changed files with 5 additions and 3 deletions

View File

@ -43,7 +43,8 @@ func main() {
return c.Query("access_token")
}))
api.GET("/test", func(c *gin.Context) {
c.String(http.StatusOK, "ok")
ti, _ := c.Get("Token")
c.JSON(http.StatusOK, ti)
})
}

View File

@ -16,7 +16,7 @@ func main() {
g := gin.Default()
g.GET("/authorize", server.HandleAuthorizeRequest)
g.POST("/token", server.HandleTokenRequest)
g.GET("/token", server.HandleTokenRequest)
api := g.Group("/api")
{
api.Use(server.TokenAuth(tokenAuthHandle))
@ -47,5 +47,6 @@ func tokenAuthHandle(c *gin.Context) (token string) {
}
func testHandle(c *gin.Context) {
c.String(http.StatusOK, "ok")
ti, _ := c.Get("Token")
c.JSON(http.StatusOK, ti)
}