Skip to content

Commit e3f4483

Browse files
committed
appease linter
1 parent 0c9c56d commit e3f4483

File tree

5 files changed

+108
-159
lines changed

5 files changed

+108
-159
lines changed

http/http_example_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func ExampleWrap() {
2525
appHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2626
w.Header().Set("Content-Type", "application/json")
2727
w.Header().Set("Date", "Mon, 01 Jan 2024 00:00:00 GMT") // Fixed date for testing
28-
fmt.Fprint(w, `{"message": "Hello, signed world!"}`)
28+
_, _ = fmt.Fprint(w, `{"message": "Hello, signed world!"}`)
2929
})
3030

3131
// Create fixed clock for deterministic timestamps
@@ -87,7 +87,7 @@ func ExampleNewClient() {
8787
// Create the application handler
8888
appHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
8989
w.Header().Set("Content-Type", "application/json")
90-
fmt.Fprint(w, `{"status": "success"}`)
90+
_, _ = fmt.Fprint(w, `{"status": "success"}`)
9191
})
9292

9393
// Wrap with just response signing for now (verification can be added separately)
@@ -115,7 +115,7 @@ func ExampleNewClient() {
115115
fmt.Printf("Request failed: %v\n", err)
116116
return
117117
}
118-
defer resp.Body.Close()
118+
defer func() { _ = resp.Body.Close() }()
119119

120120
// Only print if something went wrong
121121
if resp.StatusCode != http.StatusOK {

http/http_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func testHandler(message string) http.Handler {
3737
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
3838
w.Header().Set("Content-Type", "text/plain")
3939
w.WriteHeader(http.StatusOK)
40-
fmt.Fprint(w, message)
40+
_, _ = fmt.Fprint(w, message)
4141
})
4242
}
4343

@@ -139,7 +139,7 @@ func TestSigningTransport(t *testing.T) {
139139
w.Header().Set("X-Signature", r.Header.Get("Signature"))
140140
w.Header().Set("X-Signature-Input", r.Header.Get("Signature-Input"))
141141
w.WriteHeader(http.StatusOK)
142-
fmt.Fprint(w, "ok")
142+
_, _ = fmt.Fprint(w, "ok")
143143
}))
144144
defer server.Close()
145145

@@ -150,7 +150,7 @@ func TestSigningTransport(t *testing.T) {
150150
// Make a request
151151
resp, err := client.Get(server.URL + "/test")
152152
require.NoError(t, err)
153-
defer resp.Body.Close()
153+
defer func() { _ = resp.Body.Close() }()
154154

155155
// Check that signature headers were added
156156
require.NotEmpty(t, resp.Header.Get("X-Signature"))
@@ -241,7 +241,7 @@ func TestErrorHandling(t *testing.T) {
241241
t.Run("Custom error handler", func(t *testing.T) {
242242
customHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
243243
w.WriteHeader(http.StatusForbidden)
244-
fmt.Fprint(w, "Custom error response")
244+
_, _ = fmt.Fprint(w, "Custom error response")
245245
})
246246

247247
verifier := htmsighttp.NewVerifier(&htmsighttp.StaticKeyResolver{Key: testPublicKey})

http/signer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ func (w *signingResponseWriter) addSignatureHeaders() {
178178
inputValue := input.NewValueBuilder().AddDefinition(def).MustBuild()
179179

180180
// Prepare context with response information
181-
ctx := component.WithResponseInfo(context.Background(), w.ResponseWriter.Header(), w.statusCode,
181+
ctx := component.WithResponseInfo(context.Background(), w.Header(), w.statusCode,
182182
component.RequestInfoFromHTTP(w.request))
183183

184184
// Sign the response using the new SignResponse API
185-
err := htmsig.SignResponse(ctx, w.ResponseWriter.Header(), inputValue, w.signer.Key)
185+
err := htmsig.SignResponse(ctx, w.Header(), inputValue, w.signer.Key)
186186
if err != nil {
187187
// Handle signing error based on configuration
188188
if w.signer.ErrorHandler != nil {

http/verifier.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,6 @@ func DefaultErrorHandler() http.Handler {
190190
// VerifierOption configures a Verifier.
191191
type VerifierOption = option.Interface
192192

193-
type verifierOption struct {
194-
maxSignatureAge *time.Duration
195-
requiredComponents []component.Identifier
196-
allowedAlgorithms []string
197-
skipOnMissing *bool
198-
errorHandler http.Handler
199-
}
200-
201193
// WithMaxSignatureAge configures maximum signature age for replay protection.
202194
func WithMaxSignatureAge(maxAge time.Duration) VerifierOption {
203195
return option.New(identMaxSignatureAge{}, maxAge)

0 commit comments

Comments
 (0)