@@ -92,7 +92,7 @@ func Example_getTokenViaHTTP() {
92
92
// Read the token out of the response body
93
93
buf , err := io .ReadAll (res .Body )
94
94
fatal (err )
95
- res .Body .Close ()
95
+ _ = res .Body .Close ()
96
96
tokenString := strings .TrimSpace (string (buf ))
97
97
98
98
// Parse the token
@@ -104,7 +104,7 @@ func Example_getTokenViaHTTP() {
104
104
fatal (err )
105
105
106
106
claims := token .Claims .(* CustomClaimsExample )
107
- fmt .Println (claims .CustomerInfo . Name )
107
+ fmt .Println (claims .Name )
108
108
109
109
// Output: test
110
110
}
@@ -126,7 +126,7 @@ func Example_useTokenViaHTTP() {
126
126
// Read the response body
127
127
buf , err := io .ReadAll (res .Body )
128
128
fatal (err )
129
- res .Body .Close ()
129
+ _ = res .Body .Close ()
130
130
fmt .Printf ("%s" , buf )
131
131
132
132
// Output: Welcome, foo
@@ -156,7 +156,7 @@ func authHandler(w http.ResponseWriter, r *http.Request) {
156
156
// make sure its post
157
157
if r .Method != "POST" {
158
158
w .WriteHeader (http .StatusBadRequest )
159
- fmt .Fprintln (w , "No POST" , r .Method )
159
+ _ , _ = fmt .Fprintln (w , "No POST" , r .Method )
160
160
return
161
161
}
162
162
@@ -168,21 +168,21 @@ func authHandler(w http.ResponseWriter, r *http.Request) {
168
168
// check values
169
169
if user != "test" || pass != "known" {
170
170
w .WriteHeader (http .StatusForbidden )
171
- fmt .Fprintln (w , "Wrong info" )
171
+ _ , _ = fmt .Fprintln (w , "Wrong info" )
172
172
return
173
173
}
174
174
175
175
tokenString , err := createToken (user )
176
176
if err != nil {
177
177
w .WriteHeader (http .StatusInternalServerError )
178
- fmt .Fprintln (w , "Sorry, error while Signing Token!" )
178
+ _ , _ = fmt .Fprintln (w , "Sorry, error while Signing Token!" )
179
179
log .Printf ("Token Signing error: %v\n " , err )
180
180
return
181
181
}
182
182
183
183
w .Header ().Set ("Content-Type" , "application/jwt" )
184
184
w .WriteHeader (http .StatusOK )
185
- fmt .Fprintln (w , tokenString )
185
+ _ , _ = fmt .Fprintln (w , tokenString )
186
186
}
187
187
188
188
// only accessible with a valid token
@@ -197,10 +197,10 @@ func restrictedHandler(w http.ResponseWriter, r *http.Request) {
197
197
// If the token is missing or invalid, return error
198
198
if err != nil {
199
199
w .WriteHeader (http .StatusUnauthorized )
200
- fmt .Fprintln (w , "Invalid token:" , err )
200
+ _ , _ = fmt .Fprintln (w , "Invalid token:" , err )
201
201
return
202
202
}
203
203
204
204
// Token is valid
205
- fmt .Fprintln (w , "Welcome," , token .Claims .(* CustomClaimsExample ).Name )
205
+ _ , _ = fmt .Fprintln (w , "Welcome," , token .Claims .(* CustomClaimsExample ).Name )
206
206
}
0 commit comments