@@ -63,35 +63,34 @@ func NewWithClaims(method SigningMethod, claims Claims) *Token {
63
63
// SignedString creates and returns a complete, signed JWT. The token is signed
64
64
// using the SigningMethod specified in the token.
65
65
func (t * Token ) SignedString (key interface {}) (string , error ) {
66
- var sig , sstr string
67
- var err error
68
- if sstr , err = t .SigningString (); err != nil {
66
+ sstr , err := t .SigningString ()
67
+ if err != nil {
69
68
return "" , err
70
69
}
71
- if sig , err = t .Method .Sign (sstr , key ); err != nil {
70
+
71
+ sig , err := t .Method .Sign (sstr , key )
72
+ if err != nil {
72
73
return "" , err
73
74
}
74
- return strings .Join ([]string {sstr , sig }, "." ), nil
75
+
76
+ return sstr + "." + sig , nil
75
77
}
76
78
77
79
// SigningString generates the signing string. This is the most expensive part
78
80
// of the whole deal. Unless you need this for something special, just go
79
81
// straight for the SignedString.
80
82
func (t * Token ) SigningString () (string , error ) {
81
- var err error
82
- var jsonValue []byte
83
-
84
- if jsonValue , err = json .Marshal (t .Header ); err != nil {
83
+ h , err := json .Marshal (t .Header )
84
+ if err != nil {
85
85
return "" , err
86
86
}
87
- header := EncodeSegment (jsonValue )
88
87
89
- if jsonValue , err = json .Marshal (t .Claims ); err != nil {
88
+ c , err := json .Marshal (t .Claims )
89
+ if err != nil {
90
90
return "" , err
91
91
}
92
- claim := EncodeSegment (jsonValue )
93
92
94
- return strings . Join ([] string { header , claim }, "." ), nil
93
+ return EncodeSegment ( h ) + "." + EncodeSegment ( c ), nil
95
94
}
96
95
97
96
// Parse parses, validates, verifies the signature and returns the parsed token.
0 commit comments