github.com/yandex/pandora@v0.5.32/components/phttp/import/import.go (about) 1 package phttp 2 3 import ( 4 "github.com/spf13/afero" 5 phttp "github.com/yandex/pandora/components/guns/http" 6 scenarioGun "github.com/yandex/pandora/components/guns/http_scenario" 7 httpProvider "github.com/yandex/pandora/components/providers/http" 8 scenarioProvider "github.com/yandex/pandora/components/providers/scenario/import" 9 "github.com/yandex/pandora/core" 10 "github.com/yandex/pandora/core/register" 11 "github.com/yandex/pandora/lib/answlog" 12 ) 13 14 func Import(fs afero.Fs) { 15 httpProvider.Import(fs) 16 scenarioGun.Import(fs) 17 scenarioProvider.Import(fs) 18 19 register.Gun("http", func(conf phttp.GunConfig) func() core.Gun { 20 targetResolved, _ := phttp.PreResolveTargetAddr(&conf.Client, conf.Target) 21 conf.TargetResolved = targetResolved 22 answLog := answlog.Init(conf.AnswLog.Path, conf.AnswLog.Enabled) 23 return func() core.Gun { return phttp.WrapGun(phttp.NewHTTP1Gun(conf, answLog)) } 24 }, phttp.DefaultHTTPGunConfig) 25 26 register.Gun("http2", func(conf phttp.GunConfig) func() (core.Gun, error) { 27 targetResolved, _ := phttp.PreResolveTargetAddr(&conf.Client, conf.Target) 28 conf.TargetResolved = targetResolved 29 answLog := answlog.Init(conf.AnswLog.Path, conf.AnswLog.Enabled) 30 return func() (core.Gun, error) { 31 gun, err := phttp.NewHTTP2Gun(conf, answLog) 32 return phttp.WrapGun(gun), err 33 } 34 }, phttp.DefaultHTTP2GunConfig) 35 36 register.Gun("connect", func(conf phttp.GunConfig) func() core.Gun { 37 conf.Target, _ = phttp.PreResolveTargetAddr(&conf.Client, conf.Target) 38 conf.TargetResolved = conf.Target 39 answLog := answlog.Init(conf.AnswLog.Path, conf.AnswLog.Enabled) 40 return func() core.Gun { 41 return phttp.WrapGun(phttp.NewConnectGun(conf, answLog)) 42 } 43 }, phttp.DefaultConnectGunConfig) 44 }