Let users care about http.Client transport and keep a uniform code style
@@ -49,11 +49,10 @@ type (
// Filter is http filter instance
Filter struct {
cfg *Config
+ transport http3.RoundTripper
}
// Config describe the config of Filter
- Config struct {
- client *http3.Client
- }
+ Config struct{}
)
func (p *Plugin) Kind() string {
@@ -61,7 +60,7 @@ func (p *Plugin) Kind() string {
}
func (p *Plugin) CreateFilter() (filter.HttpFilter, error) {
- return &Filter{cfg: &Config{client: &http3.Client{}}}, nil
+ return &Filter{cfg: &Config{}, transport: &http3.Transport{}}, nil
}
func (f *Filter) Config() interface{} {
@@ -135,7 +134,7 @@ func (f *Filter) Handle(hc *http.HttpContext) {
req.Header = r.Header
errPrefix = "do request"
- resp, err := f.cfg.client.Do(req)
+ resp, err := (&http3.Client{Transport: f.transport}).Do(req)
if err != nil {
panic(err)
}
