|
|
@@ -6,27 +6,15 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-const (
|
|
|
- dialTimeout = 30 * time.Second
|
|
|
- responseHeaderTimeout = 30 * time.Second
|
|
|
-)
|
|
|
-
|
|
|
-func NewHandler(endpoints []string) (http.Handler, error) {
|
|
|
+func NewHandler(t *http.Transport, endpoints []string) (http.Handler, error) {
|
|
|
d, err := newDirector(endpoints)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- tr := http.Transport{
|
|
|
- Dial: func(network, address string) (net.Conn, error) {
|
|
|
- return net.DialTimeout(network, address, dialTimeout)
|
|
|
- },
|
|
|
- ResponseHeaderTimeout: responseHeaderTimeout,
|
|
|
- }
|
|
|
-
|
|
|
rp := reverseProxy{
|
|
|
director: d,
|
|
|
- transport: &tr,
|
|
|
+ transport: t,
|
|
|
}
|
|
|
|
|
|
return &rp, nil
|