Documentation
¶
Overview ¶
Package response handles OpenRTB bid response processing. It provides per-format response item types (banner, direct, native, vast) as well as the top-level BidResponse that aggregates all bid items.
@project GeniusRabbit corelib 2016 - 2019, 2024 - 2025 @author Dmitry Ponomarev <demdxx@gmail.com> 2016 - 2019, 2024 - 2025
Package response handles the processing and manipulation of OpenRTB bid responses. This file contains the BidResponse implementation which handles the preparation of bid responses, extraction of optimal bids, and conversion of OpenRTB bid responses into standardised ad response items.
The BidResponse struct manages the lifecycle of OpenRTB bid responses including:
- Response preparation and URL/markup handling
- Bid validation and optimisation
- Format detection and response item creation
- Price calculation and adjustment
Index ¶
- Variables
- type BidResponse
- func (r *BidResponse) Ads() []adtype.ResponseItemCommon
- func (r *BidResponse) AuctionID() string
- func (r *BidResponse) AuctionType() types.AuctionType
- func (r *BidResponse) Context(ctx ...context.Context) context.Context
- func (r *BidResponse) Count() int
- func (r *BidResponse) Error() error
- func (r *BidResponse) Get(key string) any
- func (r *BidResponse) Item(impid string) adtype.ResponseItemCommon
- func (r *BidResponse) IterAds() iter.Seq[adtype.ResponseItem]
- func (r *BidResponse) OptimalBids() []*openrtb.Bid
- func (r *BidResponse) Prepare(rules rtbrules.RTBRuler)
- func (r *BidResponse) Release()
- func (r *BidResponse) Request() adtype.BidRequester
- func (r *BidResponse) Source() adtype.Source
- func (r *BidResponse) Validate() error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidAdContent is returned when the ad markup cannot be resolved to usable content. ErrInvalidAdContent = errors.New("invalid ad content") // ErrInvalidVAST is returned when the VAST document structure is not valid. ErrInvalidVAST = errors.New("invalid VAST response") // ErrUnsupportedVASTConfiguration is returned for VAST configuration errors. ErrUnsupportedVASTConfiguration = errors.New("unsupported VAST configuration") )
Sentinel errors for ad response validation.
Functions ¶
This section is empty.
Types ¶
type BidResponse ¶
type BidResponse struct {
// Request and source information
Req adtype.BidRequester
Src adtype.Source
// BidResponse RTB record
BidResponse openrtb.BidResponse
// contains filtered or unexported fields
}
BidResponse represents an OpenRTB bid response with additional processing capabilities. It encapsulates the original OpenRTB response along with request context and derived data.
func (*BidResponse) Ads ¶
func (r *BidResponse) Ads() []adtype.ResponseItemCommon
Ads returns the list of processed ad items derived from the bid response.
func (*BidResponse) AuctionID ¶
func (r *BidResponse) AuctionID() string
AuctionID returns the auction identifier from the bid response. This is the ID that was originally passed in the bid request.
func (*BidResponse) AuctionType ¶
func (r *BidResponse) AuctionType() types.AuctionType
AuctionType returns the auction type from the original bid request.
func (*BidResponse) Context ¶
func (r *BidResponse) Context(ctx ...context.Context) context.Context
Context gets or sets the context for this response.
func (*BidResponse) Count ¶
func (r *BidResponse) Count() int
Count returns the total number of bids in the response.
func (*BidResponse) Error ¶
func (r *BidResponse) Error() error
Error returns the validation error, if any.
func (*BidResponse) Get ¶
func (r *BidResponse) Get(key string) any
Get retrieves a value from the response context by key.
func (*BidResponse) Item ¶
func (r *BidResponse) Item(impid string) adtype.ResponseItemCommon
Item returns a specific ad item by impression ID. Returns nil if no matching item is found.
func (*BidResponse) IterAds ¶
func (r *BidResponse) IterAds() iter.Seq[adtype.ResponseItem]
IterAds returns an iterator over the ad items in the response.
func (*BidResponse) OptimalBids ¶
func (r *BidResponse) OptimalBids() []*openrtb.Bid
OptimalBids returns the most expensive bid for each impression. Results are cached after the first call.
func (*BidResponse) Prepare ¶
func (r *BidResponse) Prepare(rules rtbrules.RTBRuler)
Prepare processes the bid response to make it ready for use in ad serving. This includes processing bid markup and URLs, replacing macros in creative content, extracting optimal bids, and creating standardised ad objects.
func (*BidResponse) Release ¶
func (r *BidResponse) Release()
Release frees resources used by the response. This method should be called when the response is no longer needed.
func (*BidResponse) Request ¶
func (r *BidResponse) Request() adtype.BidRequester
Request returns the original bid request associated with this response.
func (*BidResponse) Source ¶
func (r *BidResponse) Source() adtype.Source
Source returns the source of the bid response.
func (*BidResponse) Validate ¶
func (r *BidResponse) Validate() error
Validate checks if the response meets all requirements. Returns an error if the response is invalid, nil otherwise.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package banner implements the OpenRTB bid response item for banner ad formats.
|
Package banner implements the OpenRTB bid response item for banner ad formats. |
|
Package common provides BaseBidItem — the shared struct and method set that is common to every per-format RTB bid response item (banner, direct, native, vast).
|
Package common provides BaseBidItem — the shared struct and method set that is common to every per-format RTB bid response item (banner, direct, native, vast). |
|
Package direct implements the OpenRTB bid response item for direct (click URL) ad formats.
|
Package direct implements the OpenRTB bid response item for direct (click URL) ad formats. |
|
internal
|
|
|
interstitial
Package interstitial provides XML markup parsing utilities for interstitial ad formats.
|
Package interstitial provides XML markup parsing utilities for interstitial ad formats. |
|
Package native implements the OpenRTB bid response item for native ad formats.
|
Package native implements the OpenRTB bid response item for native ad formats. |
|
Package requester defines the RTBRequester interface and its implementations for executing RTB source round-trips.
|
Package requester defines the RTBRequester interface and its implementations for executing RTB source round-trips. |
|
Package vast implements the OpenRTB bid response item for VAST video ad formats.
|
Package vast implements the OpenRTB bid response item for VAST video ad formats. |