mirror of
https://github.com/aquasecurity/trivy.git
synced 2026-02-11 19:23:22 +08:00
Signed-off-by: knqyf263 <knqyf263@gmail.com> Co-authored-by: Nikita Pivkin <nikita.pivkin@smartforce.io> Co-authored-by: simar7 <1254783+simar7@users.noreply.github.com>
22 lines
491 B
Go
22 lines
491 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/twitchtv/twirp"
|
|
|
|
"github.com/aquasecurity/trivy/pkg/log"
|
|
)
|
|
|
|
// WithCustomHeaders adds custom headers to request headers
|
|
func WithCustomHeaders(ctx context.Context, customHeaders http.Header) context.Context {
|
|
// Attach the headers to a context
|
|
ctxWithToken, err := twirp.WithHTTPRequestHeaders(ctx, customHeaders)
|
|
if err != nil {
|
|
log.Warn("twirp error setting headers", log.Err(err))
|
|
return ctx
|
|
}
|
|
return ctxWithToken
|
|
}
|