From 59d226d399bd75e1265b4a1c51f05889175a0032 Mon Sep 17 00:00:00 2001 From: "junping.zhao" Date: Fri, 8 May 2020 11:11:59 +0800 Subject: [PATCH] optimized code --- adapters/yeahmobi/yeahmobi.go | 6 +----- config/config.go | 2 +- exchange/adapter_map.go | 4 ++-- openrtb_ext/bidders.go | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/adapters/yeahmobi/yeahmobi.go b/adapters/yeahmobi/yeahmobi.go index adeef637379..66c3dc7c062 100644 --- a/adapters/yeahmobi/yeahmobi.go +++ b/adapters/yeahmobi/yeahmobi.go @@ -2,7 +2,6 @@ package yeahmobi import ( "encoding/json" - "errors" "fmt" "github.com/golang/glog" "github.com/mxmCherry/openrtb" @@ -107,7 +106,7 @@ func getYeahmobiExt(request *openrtb.BidRequest) (*openrtb_ext.ExtImpYeahmobi, [ errs = append(errs, err) continue } - + break } return &extImpYeahmobi, errs @@ -115,9 +114,6 @@ func getYeahmobiExt(request *openrtb.BidRequest) (*openrtb_ext.ExtImpYeahmobi, [ } func (adapter *YeahmobiAdapter) getEndpoint(ext *openrtb_ext.ExtImpYeahmobi) (string, error) { - if ext.ZoneId == "" { - return "", errors.New("param of zoneId not config") - } return macros.ResolveMacros(adapter.EndpointTemplate, macros.EndpointTemplateParams{Host: "gw-" + url.QueryEscape(ext.ZoneId) + "-bid.yeahtargeter.com"}) } diff --git a/config/config.go b/config/config.go index b02288d76f4..33853d86a2d 100644 --- a/config/config.go +++ b/config/config.go @@ -744,10 +744,10 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.verizonmedia.disabled", true) v.SetDefault("adapters.visx.endpoint", "https://t.visx.net/s2s_bid?wrapperType=s2s_prebid_standard") v.SetDefault("adapters.vrtcal.endpoint", "http://rtb.vrtcal.com/bidder_prebid.vap?ssp=1804") + v.SetDefault("adapters.yeahmobi.endpoint", "https://{{.Host}}/prebid/bid") v.SetDefault("adapters.yieldmo.endpoint", "https://ads.yieldmo.com/exchange/prebid-server") v.SetDefault("adapters.yieldone.endpoint", "https://y.one.impact-ad.jp/hbs_imp") v.SetDefault("adapters.zeroclickfraud.endpoint", "http://{{.Host}}/openrtb2?sid={{.SourceId}}") - v.SetDefault("adapters.yeahmobi.endpoint", "https://{{.Host}}/prebid/bid") v.SetDefault("max_request_size", 1024*256) v.SetDefault("analytics.file.filename", "") diff --git a/exchange/adapter_map.go b/exchange/adapter_map.go index 7ade4796b88..46a4fe4b09d 100644 --- a/exchange/adapter_map.go +++ b/exchange/adapter_map.go @@ -2,7 +2,6 @@ package exchange import ( "fmt" - "github.com/prebid/prebid-server/adapters/yeahmobi" "net/http" "strings" @@ -65,6 +64,7 @@ import ( "github.com/prebid/prebid-server/adapters/verizonmedia" "github.com/prebid/prebid-server/adapters/visx" "github.com/prebid/prebid-server/adapters/vrtcal" + "github.com/prebid/prebid-server/adapters/yeahmobi" "github.com/prebid/prebid-server/adapters/yieldmo" "github.com/prebid/prebid-server/adapters/yieldone" "github.com/prebid/prebid-server/adapters/zeroclickfraud" @@ -140,10 +140,10 @@ func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapter openrtb_ext.BidderVerizonMedia: verizonmedia.NewVerizonMediaBidder(client, cfg.Adapters[string(openrtb_ext.BidderVerizonMedia)].Endpoint), openrtb_ext.BidderVisx: visx.NewVisxBidder(cfg.Adapters[string(openrtb_ext.BidderVisx)].Endpoint), openrtb_ext.BidderVrtcal: vrtcal.NewVrtcalBidder(cfg.Adapters[string(openrtb_ext.BidderVrtcal)].Endpoint), + openrtb_ext.BidderYeahmobi: yeahmobi.NewYeahmobiBidder(cfg.Adapters[string(openrtb_ext.BidderYeahmobi)].Endpoint), openrtb_ext.BidderYieldmo: yieldmo.NewYieldmoBidder(cfg.Adapters[string(openrtb_ext.BidderYieldmo)].Endpoint), openrtb_ext.BidderYieldone: yieldone.NewYieldoneBidder(cfg.Adapters[string(openrtb_ext.BidderYieldone)].Endpoint), openrtb_ext.BidderZeroClickFraud: zeroclickfraud.NewZeroClickFraudBidder(cfg.Adapters[string(openrtb_ext.BidderZeroClickFraud)].Endpoint), - openrtb_ext.BidderYeahmobi: yeahmobi.NewYeahmobiBidder(cfg.Adapters[string(openrtb_ext.BidderYeahmobi)].Endpoint), } legacyBidders := map[openrtb_ext.BidderName]adapters.Adapter{ diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 9d1c3c0343e..fd1555bb3ba 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -82,10 +82,10 @@ const ( BidderVerizonMedia BidderName = "verizonmedia" BidderVisx BidderName = "visx" BidderVrtcal BidderName = "vrtcal" + BidderYeahmobi BidderName = "yeahmobi" BidderYieldmo BidderName = "yieldmo" BidderYieldone BidderName = "yieldone" BidderZeroClickFraud BidderName = "zeroclickfraud" - BidderYeahmobi BidderName = "yeahmobi" ) // BidderMap stores all the valid OpenRTB 2.x Bidders in the project. This map *must not* be mutated. @@ -149,10 +149,10 @@ var BidderMap = map[string]BidderName{ "verizonmedia": BidderVerizonMedia, "visx": BidderVisx, "vrtcal": BidderVrtcal, + "yeahmobi": BidderYeahmobi, "yieldmo": BidderYieldmo, "yieldone": BidderYieldone, "zeroclickfraud": BidderZeroClickFraud, - "yeahmobi": BidderYeahmobi, } // BidderList returns the values of the BidderMap