Skip to content

Commit 271a916

Browse files
committed
Use explicit numbering for constants.
This change avoids use of iota for constants that map to the openrtb spec. This makes them more robust to reordering and addition of new values. Fixes a bug where AdPosBelowFold and related constants had the wrong values.
1 parent e402fab commit 271a916

File tree

1 file changed

+84
-84
lines changed

1 file changed

+84
-84
lines changed

openrtb.go

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,70 @@ package openrtb
22

33
// 5.2 Banner Ad Types
44
const (
5-
BannerTypeXHTMLText int = iota + 1
6-
BannerTypeXHTML
7-
BannerTypeJS
8-
BannerTypeFrame
5+
BannerTypeXHTMLText = 1
6+
BannerTypeXHTML = 2
7+
BannerTypeJS = 3
8+
BannerTypeFrame = 4
99
)
1010

1111
// 5.3 Creative Attributes
1212
// TODO
1313

1414
// 5.4 Ad Position
1515
const (
16-
AdPosUnknown int = iota
17-
AdPosAboveFold
18-
AdPosBelowFold
19-
AdPosHeader
20-
AdPosFooter
21-
AdPosSidebar
22-
AdPosFullscreen
16+
AdPosUnknown = 0
17+
AdPosAboveFold = 1
18+
AdPosBelowFold = 3
19+
AdPosHeader = 4
20+
AdPosFooter = 5
21+
AdPosSidebar = 6
22+
AdPosFullscreen = 7
2323
)
2424

2525
// 5.5 Expandable Direction
2626
const (
27-
ExpDirLeft int = iota + 1
28-
ExpDirRight
29-
ExpDirUp
30-
ExpDirDown
31-
ExpDirFullScreen
27+
ExpDirLeft = 1
28+
ExpDirRight = 2
29+
ExpDirUp = 3
30+
ExpDirDown = 4
31+
ExpDirFullScreen = 5
3232
)
3333

3434
// 5.6 API Frameworks
3535
const (
36-
APIFrameworkVPAID1 int = iota + 1
37-
APIFrameworkVPAID2
38-
APIFrameworkMRAID1
39-
APIFrameworkORMMA
40-
APIFrameworkMRAID2
36+
APIFrameworkVPAID1 = 1
37+
APIFrameworkVPAID2 = 2
38+
APIFrameworkMRAID1 = 3
39+
APIFrameworkORMMA = 4
40+
APIFrameworkMRAID2 = 5
4141
)
4242

4343
// 5.7 Video Linearity
4444
const (
45-
VideoLinearityLinear int = iota + 1
46-
VideoLinearityNonLinear
45+
VideoLinearityLinear = 1
46+
VideoLinearityNonLinear = 2
4747
)
4848

4949
// 5.8 Video and Audio Bid Response Protocols
5050
const (
51-
VideoProtoVAST1 int = iota + 1
52-
VideoProtoVAST2
53-
VideoProtoVAST3
54-
VideoProtoVAST1Wrapper
55-
VideoProtoVAST2Wrapper
56-
VideoProtoVAST3Wrapper
57-
VideoProtoVAST4
58-
VideoProtoVAST4Wrapper
59-
AudioProtocolDAAST1
60-
AudioProtocolDAAST1Wrapper
51+
VideoProtoVAST1 = 1
52+
VideoProtoVAST2 = 2
53+
VideoProtoVAST3 = 3
54+
VideoProtoVAST1Wrapper = 4
55+
VideoProtoVAST2Wrapper = 5
56+
VideoProtoVAST3Wrapper = 6
57+
VideoProtoVAST4 = 7
58+
VideoProtoVAST4Wrapper = 8
59+
AudioProtocolDAAST1 = 9
60+
AudioProtocolDAAST1Wrapper = 10
6161
)
6262

6363
// 5.9 Video Playback Methods
6464
const (
65-
VideoPlaybackAutoSoundOn int = iota + 1
66-
VideoPlaybackAutoSoundOff
67-
VideoPlaybackClickToPlay
68-
VideoPlaybackMouseOver
65+
VideoPlaybackAutoSoundOn = 1
66+
VideoPlaybackAutoSoundOff = 2
67+
VideoPlaybackClickToPlay = 3
68+
VideoPlaybackMouseOver = 4
6969
)
7070

7171
// 5.10 Video Start Delay
@@ -77,85 +77,85 @@ const (
7777

7878
// 5.11 Video Quality
7979
const (
80-
VideoQualityUnknown int = iota
81-
VideoQualityProfessional
82-
VideoQualityProsumer
83-
VideoQualityUGC
80+
VideoQualityUnknown = 0
81+
VideoQualityProfessional = 1
82+
VideoQualityProsumer = 2
83+
VideoQualityUGC = 3
8484
)
8585

8686
// 5.12 VAST Companion Types
8787
const (
88-
VASTCompanionStatic int = iota + 1
89-
VASTCompanionHTML
90-
VASTCompanionIFrame
88+
VASTCompanionStatic = 1
89+
VASTCompanionHTML = 2
90+
VASTCompanionIFrame = 3
9191
)
9292

9393
// 5.13 Content Delivery Methods
9494
const (
95-
ContentDeliveryStreaming int = iota + 1
96-
ContentDeliveryProgressive
97-
ContentDeliveryDownload
95+
ContentDeliveryStreaming = 1
96+
ContentDeliveryProgressive = 2
97+
ContentDeliveryDownload = 3
9898
)
9999

100100
// 5.14 Content Context
101101
const (
102-
ContextVideo int = iota + 1
103-
ContextGame
104-
ContextMusic
105-
ContextApplication
106-
ContextText
107-
ContextOther
108-
ContextUnknown
102+
ContextVideo = 1
103+
ContextGame = 2
104+
ContextMusic = 3
105+
ContextApplication = 4
106+
ContextText = 5
107+
ContextOther = 6
108+
ContextUnknown = 7
109109
)
110110

111111
// 5.15 QAG Media Ratings
112112
const (
113-
QAGAll int = iota + 1
114-
QAGOver12
115-
QAGMature
113+
QAGAll = 1
114+
QAGOver12 = 2
115+
QAGMature = 3
116116
)
117117

118118
// 5.16 Location Type
119119
const (
120-
LocationTypeGPS int = iota + 1
121-
LocationTypeIP
122-
LocationTypeUser
120+
LocationTypeGPS = 1
121+
LocationTypeIP = 2
122+
LocationTypeUser = 3
123123
)
124124

125125
// 5.17 Device Type
126126
const (
127-
DeviceTypeUnknown int = iota
128-
DeviceTypeMobile
129-
DeviceTypePC
130-
DeviceTypeTV
131-
DeviceTypePhone
132-
DeviceTypeTablet
133-
DeviceTypeConnected
134-
DeviceTypeSetTopBox
127+
DeviceTypeUnknown = 1
128+
DeviceTypeMobile = 2
129+
DeviceTypePC = 3
130+
DeviceTypeTV = 4
131+
DeviceTypePhone = 5
132+
DeviceTypeTablet = 6
133+
DeviceTypeConnected = 7
134+
DeviceTypeSetTopBox = 8
135135
)
136136

137137
// 5.18 Connection Type
138138
const (
139-
ConnTypeUnknown int = iota
140-
ConnTypeEthernet
141-
ConnTypeWIFI
142-
ConnTypeCell
143-
ConnTypeCell2G
144-
ConnTypeCell3G
145-
ConnTypeCell4G
139+
ConnTypeUnknown = 0
140+
ConnTypeEthernet = 1
141+
ConnTypeWIFI = 2
142+
ConnTypeCell = 3
143+
ConnTypeCell2G = 4
144+
ConnTypeCell3G = 5
145+
ConnTypeCell4G = 6
146146
)
147147

148148
// 5.19 No-Bid Reason Codes
149149
const (
150-
NBRUnknownError int = iota
151-
NBRTechnicalError
152-
NBRInvalidRequest
153-
NBRKnownSpider
154-
NBRSuspectedNonHuman
155-
NBRProxyIP
156-
NBRUnsupportedDevice
157-
NBRBlockedSite
158-
NBRUnmatchedUser
150+
NBRUnknownError = 0
151+
NBRTechnicalError = 1
152+
NBRInvalidRequest = 2
153+
NBRKnownSpider = 3
154+
NBRSuspectedNonHuman = 4
155+
NBRProxyIP = 5
156+
NBRUnsupportedDevice = 6
157+
NBRBlockedSite = 7
158+
NBRUnmatchedUser = 8
159159
)
160160

161161
/*************************************************************************

0 commit comments

Comments
 (0)