39 lines
672 B
Go
39 lines
672 B
Go
|
package oidc
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type Options struct {
|
||
|
HTTPTransport *http.Transport
|
||
|
HTTPClientTimeout time.Duration
|
||
|
}
|
||
|
|
||
|
type OptionFunc func(opts *Options)
|
||
|
|
||
|
func WithHTTPTransport(transport *http.Transport) OptionFunc {
|
||
|
return func(opts *Options) {
|
||
|
opts.HTTPTransport = transport
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func WithHTTPClientTimeout(timeout time.Duration) OptionFunc {
|
||
|
return func(opts *Options) {
|
||
|
opts.HTTPClientTimeout = timeout
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func NewOptions(funcs ...OptionFunc) *Options {
|
||
|
opts := &Options{
|
||
|
HTTPTransport: http.DefaultTransport.(*http.Transport),
|
||
|
HTTPClientTimeout: 30 * time.Second,
|
||
|
}
|
||
|
|
||
|
for _, fn := range funcs {
|
||
|
fn(opts)
|
||
|
}
|
||
|
|
||
|
return opts
|
||
|
}
|