Skip to content

Media.net adapter: support regional (geo-routed) endpoints #4827

Description

@anishb-ms

Background / Motivation
Media.net currently routes all server-to-server bid traffic through a single global endpoint (https://prebid-adapter.media.net/rtb/pb/prebids2s). To reduce latency and route requests to the nearest datacenter, Media.net is introducing regional endpoints:

Geo code: USE
Region: US East
Endpoint: https://prebid-adapter-useast.media.net/rtb/pb/prebids2s

Geo code: USW
Region: US West
Endpoint: https://prebid-adapter-uswest.media.net/rtb/pb/prebids2s

Geo code: APAC
Region: Asia
Endpoint: https://prebid-adapter-asia.media.net/rtb/pb/prebids2s

Geo code: EUC
Region: Europe Central
Endpoint: https://prebid-adapter-eu.media.net/rtb/pb/prebids2s

Because Prebid Server deployments are operated by many different hosts (not Media.net), the region cannot be selected from the server’s deployment/config. It has to travel in the bid request, so the routing decision is request-driven.

Proposed implementation

  1. New optional imp param region in medianet.json, constrained to an enum: ["USE", "USW", "APAC", "EUC"]. It is not required, preserving backward compatibility.

  2. ExtImpMedianet (imp_medianet.go) gains a Region string json:"region,omitempty"`` field.

  3. medianet.yaml endpoint becomes a template using the standard {{.Host}} macro:
    endpoint: "https://{{.Host}}/rtb/pb/prebids2s"

  4. Adapter (medianet.go):

  • Builder now parses the endpoint as a text/template
  • The region is read from the first impression’s bidder params.
{
    "id": "test-region-use",
    "test": 1,
    "ext": { "prebid": { "debug": true } },
    "imp": [{
      "id": "1",
      "banner": { "format": [{ "w": 300, "h": 250 }] },
      "ext": {
        "prebid": {
          "bidder": {
            "medianet": { "cid": "xxxxxxx", "crid": "xxxxxxx", "region": "USE" }
          }
        }
      }
    }]
  }
  • getRegionHost(region) maps the geo code to the regional host and is resolved via macros.ResolveMacros.
  • The existing src query param (derived from extra_info) is preserved.
  • Matching is case-insensitive; an empty or unrecognized region falls back to the current default host prebid-adapter.media.net, so existing integrations are unaffected.

Backward compatibility

  • region is optional. Requests without it resolve to https://prebid-adapter.media.net/rtb/pb/prebids2s — identical to today’s behavior.
  • No change to request/response bodies; region simply passes through inside imp.ext like the existing cid/crid params.

Testing

  • Updated the JSON test harness endpoint to the templated host and refreshed expected URIs.
  • Added an exemplary JSON exercising regional routing (region: "USE" → prebid-adapter-useast.media.net).
  • Added a unit test (TestGetRegionHost) covering all four codes, case-insensitivity, and the default fallback.
  • Updated the malformed-template test to expect a build error (Builder now parses a template).
  • go build anish-ms. and go test ./adapters/medianet/... ./openrtb_ext/... prebid-server. all pass.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status
Ready for Dev

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions