/
githubmirror
/
trivy
Обзор
Документация
Войти
/
githubmirror
/
trivy
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
pkg/x/http/client.go
30 строк
607 B
Teppei Fukuda
refactor: allow per-request transport options override (#10083)
23 янв 2026, 13:23
Не верифицирован
23 янв 2026, 13:23
f97ac7e
Код
Авторство
О чём код?
package http import ( "context" "net/http" "time" ) type ClientOption func(client *http.Client) func WithTimeout(timeout time.Duration) ClientOption { return func(client *http.Client) { client.Timeout = timeout } } func Client(opts ...ClientOption) *http.Client { return ClientWithContext(context.Background(), opts...) } // ClientWithContext returns an HTTP client with the specified context and options. func ClientWithContext(ctx context.Context, opts ...ClientOption) *http.Client { c := &http.Client{ Transport: RoundTripper(ctx), } for _, opt := range opts { opt(c) } return c }