yet more documentation

This commit is contained in:
Dave Grijalva 2014-05-19 20:25:30 -07:00
parent a94bf1842f
commit e066f61666
1 changed files with 6 additions and 4 deletions

View File

@ -80,7 +80,8 @@ func loadData(p string) ([]byte, error) {
return ioutil.ReadAll(rdr) return ioutil.ReadAll(rdr)
} }
// Verify a token and output the claims // Verify a token and output the claims. This is a great example
// of how to verify and view a token.
func verifyToken() error { func verifyToken() error {
// get the token // get the token
tokData, err := loadData(*flagVerify) tokData, err := loadData(*flagVerify)
@ -95,7 +96,7 @@ func verifyToken() error {
// Print an error if we can't parse for some reason // Print an error if we can't parse for some reason
if err != nil { if err != nil {
return err return fmt.Errorf("Couldn't parse token: %v", err)
} }
// Is token invalid? // Is token invalid?
@ -114,9 +115,10 @@ func verifyToken() error {
return nil return nil
} }
// Create, sign, and output a token // Create, sign, and output a token. This is a great, simple example of
// how to use this library to create and sign a token.
func signToken() error { func signToken() error {
// get the token // get the token data from command line arguments
tokData, err := loadData(*flagSign) tokData, err := loadData(*flagSign)
if err != nil { if err != nil {
return fmt.Errorf("Couldn't read token: %v", err) return fmt.Errorf("Couldn't read token: %v", err)