Skip to content

Commit 8fe5e8b

Browse files
authored
add MaxConnDuration option for hostClient
1 parent f04a704 commit 8fe5e8b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

reverseproxy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func (p *ReverseProxy) init() error {
8484
IsTLS: p.opt.tlsConfig != nil,
8585
TLSConfig: p.opt.tlsConfig,
8686
DisablePathNormalizing: p.opt.disablePathNormalizing,
87+
MaxConnDuration: p.opt.maxConnDuration,
8788
}
8889
p.clients = append(p.clients, client)
8990
return nil

reverseproxy_option.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ type buildOption struct {
3636

3737
// disablePathNormalizing disable path normalizing.
3838
disablePathNormalizing bool
39+
40+
// maxConnDuration of hostClient
41+
maxConnDuration time.Duration
3942
}
4043

4144
func defaultBuildOption() *buildOption {
@@ -119,3 +122,10 @@ func WithDisablePathNormalizing(isDisablePathNormalizing bool) Option {
119122
o.disablePathNormalizing = isDisablePathNormalizing
120123
})
121124
}
125+
126+
// WithTimeout specify the timeout of each request
127+
func WithMaxConnDuration(d time.Duration) Option {
128+
return newFuncBuildOption(func(o *buildOption) {
129+
o.maxConnDuration = d
130+
})
131+
}

0 commit comments

Comments
 (0)