File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
4144func defaultBuildOption () * buildOption {
@@ -48,6 +51,7 @@ func defaultBuildOption() *buildOption {
4851 tlsConfig : nil ,
4952 timeout : 0 ,
5053 disablePathNormalizing : false ,
54+ maxConnDuration : 0 ,
5155 }
5256}
5357
@@ -119,3 +123,11 @@ func WithDisablePathNormalizing(isDisablePathNormalizing bool) Option {
119123 o .disablePathNormalizing = isDisablePathNormalizing
120124 })
121125}
126+
127+ // WithMaxConnDuration sets maxConnDuration of hostClient, which
128+ // means keep-alive connections are closed after this duration.
129+ func WithMaxConnDuration (d time.Duration ) Option {
130+ return newFuncBuildOption (func (o * buildOption ) {
131+ o .maxConnDuration = d
132+ })
133+ }
You can’t perform that action at this time.
0 commit comments