From ba4268888e83bc3120d92e731ba98740b084a6f2 Mon Sep 17 00:00:00 2001 From: Porjo Date: Fri, 21 Feb 2014 08:39:45 +1000 Subject: [PATCH] gofmt README examples Conflicts: README.md --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a4ee874..24b60e8 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,25 @@ This library supports the parsing and verification as well as the generation and This library is considered production ready. Feedback and feature requests are appreciated. ## Parse and Verify - - token, err := jwt.Parse(myToken, func(token *jwt.Token)([]byte, error){ - return myLookupKey(token.Head["kid"]) +```go + token, err := jwt.Parse(myToken, func(token *jwt.Token) ([]byte, error) { + return myLookupKey(token.Header["kid"]) }) - + if !err && token.Valid { deliverGoodness("!") } else { deliverUtterRejection(":(") } +``` ## Create a token - - token := jwt.New(jwt.GetSigningMethod("HS256")) + +```go + token, _ := jwt.New(jwt.GetSigningMethod("HS256")) token.Claims["foo"] = "bar" token.Claims["exp"] = time.Now().Add(time.Hour * 72).Unix() tokenString, err := token.SignedString(mySigningKey) +``` + +Documentation can be found [here](http://godoc.org/github.com/dgrijalva/jwt-go) \ No newline at end of file