@@ -20,11 +20,6 @@ import (
2020var (
2121 // Tibiadata app resty vars
2222 TibiadataUserAgent , TibiadataProxyDomain string
23- TibiadataRequest = TibiadataRequestStruct {
24- Method : resty .MethodGet ,
25- URL : "" ,
26- FormData : make (map [string ]string ),
27- }
2823)
2924
3025// Information - child of JSONData
@@ -143,23 +138,29 @@ func tibiaCharactersCharacterV3(c *gin.Context) {
143138 // getting params from URL
144139 character := c .Param ("character" )
145140
146- // Getting data with TibiadataHTMLDataCollectorV3
147- TibiadataRequest .URL = "https://www.tibia.com/community/?subtopic=characters&name=" + TibiadataQueryEscapeStringV3 (character )
141+ tibiadataRequest := TibiadataRequestStruct {
142+ Method : resty .MethodGet ,
143+ URL : "https://www.tibia.com/community/?subtopic=characters&name=" + TibiadataQueryEscapeStringV3 (character ),
144+ }
148145
149146 tibiaDataRequestHandler (
150147 c ,
148+ tibiadataRequest ,
151149 func (BoxContentHTML string ) (interface {}, int ) {
152150 return TibiaCharactersCharacterV3Impl (BoxContentHTML ), http .StatusOK
153151 },
154152 "TibiaCharactersCharacterV3" )
155153}
156154
157155func tibiaCreaturesOverviewV3 (c * gin.Context ) {
158- // Getting data with TibiadataHTMLDataCollectorV3
159- TibiadataRequest .URL = "https://www.tibia.com/library/?subtopic=creatures"
156+ tibiadataRequest := TibiadataRequestStruct {
157+ Method : resty .MethodGet ,
158+ URL : "https://www.tibia.com/library/?subtopic=creatures" ,
159+ }
160160
161161 tibiaDataRequestHandler (
162162 c ,
163+ tibiadataRequest ,
163164 func (BoxContentHTML string ) (interface {}, int ) {
164165 return TibiaCreaturesOverviewV3Impl (BoxContentHTML ), http .StatusOK
165166 },
@@ -170,23 +171,29 @@ func tibiaCreaturesCreatureV3(c *gin.Context) {
170171 // getting params from URL
171172 race := c .Param ("race" )
172173
173- // Getting data with TibiadataHTMLDataCollectorV3
174- TibiadataRequest .URL = "https://www.tibia.com/library/?subtopic=creatures&race=" + TibiadataQueryEscapeStringV3 (race )
174+ tibiadataRequest := TibiadataRequestStruct {
175+ Method : resty .MethodGet ,
176+ URL : "https://www.tibia.com/library/?subtopic=creatures&race=" + TibiadataQueryEscapeStringV3 (race ),
177+ }
175178
176179 tibiaDataRequestHandler (
177180 c ,
181+ tibiadataRequest ,
178182 func (BoxContentHTML string ) (interface {}, int ) {
179183 return TibiaCreaturesCreatureV3Impl (race , BoxContentHTML ), http .StatusOK
180184 },
181185 "TibiaCreaturesCreatureV3" )
182186}
183187
184188func tibiaFansitesV3 (c * gin.Context ) {
185- // Getting data with TibiadataHTMLDataCollectorV3
186- TibiadataRequest .URL = "https://www.tibia.com/community/?subtopic=fansites"
189+ tibiadataRequest := TibiadataRequestStruct {
190+ Method : resty .MethodGet ,
191+ URL : "https://www.tibia.com/community/?subtopic=fansites" ,
192+ }
187193
188194 tibiaDataRequestHandler (
189195 c ,
196+ tibiadataRequest ,
190197 func (BoxContentHTML string ) (interface {}, int ) {
191198 return TibiaFansitesV3Impl (BoxContentHTML ), http .StatusOK
192199 },
@@ -197,11 +204,14 @@ func tibiaGuildsGuildV3(c *gin.Context) {
197204 // getting params from URL
198205 guild := c .Param ("guild" )
199206
200- // Getting data with TibiadataHTMLDataCollectorV3
201- TibiadataRequest .URL = "https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=" + TibiadataQueryEscapeStringV3 (guild )
207+ tibiadataRequest := TibiadataRequestStruct {
208+ Method : resty .MethodGet ,
209+ URL : "https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=" + TibiadataQueryEscapeStringV3 (guild ),
210+ }
202211
203212 tibiaDataRequestHandler (
204213 c ,
214+ tibiadataRequest ,
205215 func (BoxContentHTML string ) (interface {}, int ) {
206216 return TibiaGuildsGuildV3Impl (guild , BoxContentHTML ), http .StatusOK
207217 },
@@ -215,11 +225,14 @@ func tibiaGuildsOverviewV3(c *gin.Context) {
215225 // Adding fix for First letter to be upper and rest lower
216226 world = TibiadataStringWorldFormatToTitleV3 (world )
217227
218- // Getting data with TibiadataHTMLDataCollectorV3
219- TibiadataRequest .URL = "https://www.tibia.com/community/?subtopic=guilds&world=" + TibiadataQueryEscapeStringV3 (world )
228+ tibiadataRequest := TibiadataRequestStruct {
229+ Method : resty .MethodGet ,
230+ URL : "https://www.tibia.com/community/?subtopic=guilds&world=" + TibiadataQueryEscapeStringV3 (world ),
231+ }
220232
221233 tibiaDataRequestHandler (
222234 c ,
235+ tibiadataRequest ,
223236 func (BoxContentHTML string ) (interface {}, int ) {
224237 return TibiaGuildsOverviewV3Impl (world , BoxContentHTML ), http .StatusOK
225238 },
@@ -246,11 +259,14 @@ func tibiaHighscoresV3(c *gin.Context) {
246259 // Sanitize of vocation input
247260 vocationName , vocationid := TibiaDataVocationValidator (vocation )
248261
249- // Getting data with TibiadataHTMLDataCollectorV3
250- TibiadataRequest .URL = "https://www.tibia.com/community/?subtopic=highscores&world=" + TibiadataQueryEscapeStringV3 (world ) + "&category=" + strconv .Itoa (int (highscoreCategory )) + "&profession=" + TibiadataQueryEscapeStringV3 (vocationid ) + "¤tpage=400000000000000"
262+ tibiadataRequest := TibiadataRequestStruct {
263+ Method : resty .MethodGet ,
264+ URL : "https://www.tibia.com/community/?subtopic=highscores&world=" + TibiadataQueryEscapeStringV3 (world ) + "&category=" + strconv .Itoa (int (highscoreCategory )) + "&profession=" + TibiadataQueryEscapeStringV3 (vocationid ) + "¤tpage=400000000000000" ,
265+ }
251266
252267 tibiaDataRequestHandler (
253268 c ,
269+ tibiadataRequest ,
254270 func (BoxContentHTML string ) (interface {}, int ) {
255271 return TibiaHighscoresV3Impl (world , highscoreCategory , vocationName , BoxContentHTML ), http .StatusOK
256272 },
@@ -265,11 +281,14 @@ func tibiaHousesHouseV3(c *gin.Context) {
265281 // Adding fix for First letter to be upper and rest lower
266282 world = TibiadataStringWorldFormatToTitleV3 (world )
267283
268- // Getting data with TibiadataHTMLDataCollectorV3
269- TibiadataRequest .URL = "https://www.tibia.com/community/?subtopic=houses&page=view&world=" + TibiadataQueryEscapeStringV3 (world ) + "&houseid=" + TibiadataQueryEscapeStringV3 (houseid )
284+ tibiadataRequest := TibiadataRequestStruct {
285+ Method : resty .MethodGet ,
286+ URL : "https://www.tibia.com/community/?subtopic=houses&page=view&world=" + TibiadataQueryEscapeStringV3 (world ) + "&houseid=" + TibiadataQueryEscapeStringV3 (houseid ),
287+ }
270288
271289 tibiaDataRequestHandler (
272290 c ,
291+ tibiadataRequest ,
273292 func (BoxContentHTML string ) (interface {}, int ) {
274293 return TibiaHousesHouseV3Impl (houseid , BoxContentHTML ), http .StatusOK
275294 },
@@ -299,11 +318,14 @@ func tibiaKillstatisticsV3(c *gin.Context) {
299318 // Adding fix for First letter to be upper and rest lower
300319 world = TibiadataStringWorldFormatToTitleV3 (world )
301320
302- // Getting data with TibiadataHTMLDataCollectorV3
303- TibiadataRequest .URL = "https://www.tibia.com/community/?subtopic=killstatistics&world=" + TibiadataQueryEscapeStringV3 (world )
321+ tibiadataRequest := TibiadataRequestStruct {
322+ Method : resty .MethodGet ,
323+ URL : "https://www.tibia.com/community/?subtopic=killstatistics&world=" + TibiadataQueryEscapeStringV3 (world ),
324+ }
304325
305326 tibiaDataRequestHandler (
306327 c ,
328+ tibiadataRequest ,
307329 func (BoxContentHTML string ) (interface {}, int ) {
308330 return TibiaKillstatisticsV3Impl (world , BoxContentHTML ), http .StatusOK
309331 },
@@ -321,37 +343,40 @@ func tibiaNewslistV3(c *gin.Context) {
321343 DateBegin := time .Now ().AddDate (0 , 0 , - days )
322344 DateEnd := time .Now ()
323345
324- TibiadataRequest .Method = http .MethodPost
325- TibiadataRequest .URL = "https://www.tibia.com/news/?subtopic=newsarchive"
326- TibiadataRequest .FormData = map [string ]string {
327- "filter_begin_day" : strconv .Itoa (DateBegin .UTC ().Day ()), // period
328- "filter_begin_month" : strconv .Itoa (int (DateBegin .UTC ().Month ())), // period
329- "filter_begin_year" : strconv .Itoa (DateBegin .UTC ().Year ()), // period
330- "filter_end_day" : strconv .Itoa (DateEnd .UTC ().Day ()), // period
331- "filter_end_month" : strconv .Itoa (int (DateEnd .UTC ().Month ())), // period
332- "filter_end_year" : strconv .Itoa (DateEnd .UTC ().Year ()), // period
333- "filter_cipsoft" : "cipsoft" , // category
334- "filter_community" : "community" , // category
335- "filter_development" : "development" , // category
336- "filter_support" : "support" , // category
337- "filter_technical" : "technical" , // category
346+ tibiadataRequest := TibiadataRequestStruct {
347+ Method : http .MethodPost ,
348+ URL : "https://www.tibia.com/news/?subtopic=newsarchive" ,
349+ FormData : map [string ]string {
350+ "filter_begin_day" : strconv .Itoa (DateBegin .UTC ().Day ()), // period
351+ "filter_begin_month" : strconv .Itoa (int (DateBegin .UTC ().Month ())), // period
352+ "filter_begin_year" : strconv .Itoa (DateBegin .UTC ().Year ()), // period
353+ "filter_end_day" : strconv .Itoa (DateEnd .UTC ().Day ()), // period
354+ "filter_end_month" : strconv .Itoa (int (DateEnd .UTC ().Month ())), // period
355+ "filter_end_year" : strconv .Itoa (DateEnd .UTC ().Year ()), // period
356+ "filter_cipsoft" : "cipsoft" , // category
357+ "filter_community" : "community" , // category
358+ "filter_development" : "development" , // category
359+ "filter_support" : "support" , // category
360+ "filter_technical" : "technical" , // category
361+ },
338362 }
339363
340364 // getting type of news list
341365 switch tmp := strings .Split (c .Request .URL .Path , "/" ); tmp [3 ] {
342366 case "newsticker" :
343- TibiadataRequest .FormData ["filter_ticker" ] = "ticker"
367+ tibiadataRequest .FormData ["filter_ticker" ] = "ticker"
344368 case "latest" :
345- TibiadataRequest .FormData ["filter_article" ] = "article"
346- TibiadataRequest .FormData ["filter_news" ] = "news"
369+ tibiadataRequest .FormData ["filter_article" ] = "article"
370+ tibiadataRequest .FormData ["filter_news" ] = "news"
347371 case "archive" :
348- TibiadataRequest .FormData ["filter_ticker" ] = "ticker"
349- TibiadataRequest .FormData ["filter_article" ] = "article"
350- TibiadataRequest .FormData ["filter_news" ] = "news"
372+ tibiadataRequest .FormData ["filter_ticker" ] = "ticker"
373+ tibiadataRequest .FormData ["filter_article" ] = "article"
374+ tibiadataRequest .FormData ["filter_news" ] = "news"
351375 }
352376
353377 tibiaDataRequestHandler (
354378 c ,
379+ tibiadataRequest ,
355380 func (BoxContentHTML string ) (interface {}, int ) {
356381 return TibiaNewslistV3Impl (days , BoxContentHTML ), http .StatusOK
357382 },
@@ -368,12 +393,16 @@ func tibiaNewsV3(c *gin.Context) {
368393 return
369394 }
370395
371- TibiadataRequest .URL = "https://www.tibia.com/news/?subtopic=newsarchive&id=" + strconv .Itoa (NewsID )
396+ tibiadataRequest := TibiadataRequestStruct {
397+ Method : resty .MethodGet ,
398+ URL : "https://www.tibia.com/news/?subtopic=newsarchive&id=" + strconv .Itoa (NewsID ),
399+ }
372400
373401 tibiaDataRequestHandler (
374402 c ,
403+ tibiadataRequest ,
375404 func (BoxContentHTML string ) (interface {}, int ) {
376- return TibiaNewsV3Impl (NewsID , TibiadataRequest .URL , BoxContentHTML ), http .StatusOK
405+ return TibiaNewsV3Impl (NewsID , tibiadataRequest .URL , BoxContentHTML ), http .StatusOK
377406 },
378407 "TibiaNewsV3" )
379408}
@@ -396,11 +425,14 @@ func tibiaSpellsOverviewV3(c *gin.Context) {
396425 vocationName = strings .Title (vocationName )
397426 }
398427
399- // Getting data with TibiadataHTMLDataCollectorV3
400- TibiadataRequest .URL = "https://www.tibia.com/library/?subtopic=spells&vocation=" + TibiadataQueryEscapeStringV3 (vocationName )
428+ tibiadataRequest := TibiadataRequestStruct {
429+ Method : resty .MethodGet ,
430+ URL : "https://www.tibia.com/library/?subtopic=spells&vocation=" + TibiadataQueryEscapeStringV3 (vocationName ),
431+ }
401432
402433 tibiaDataRequestHandler (
403434 c ,
435+ tibiadataRequest ,
404436 func (BoxContentHTML string ) (interface {}, int ) {
405437 return TibiaSpellsOverviewV3Impl (vocationName , BoxContentHTML ), http .StatusOK
406438 },
@@ -411,23 +443,29 @@ func tibiaSpellsSpellV3(c *gin.Context) {
411443 // getting params from URL
412444 spell := c .Param ("spell" )
413445
414- // Getting data with TibiadataHTMLDataCollectorV3
415- TibiadataRequest .URL = "https://www.tibia.com/library/?subtopic=spells&spell=" + TibiadataQueryEscapeStringV3 (spell )
446+ tibiadataRequest := TibiadataRequestStruct {
447+ Method : resty .MethodGet ,
448+ URL : "https://www.tibia.com/library/?subtopic=spells&spell=" + TibiadataQueryEscapeStringV3 (spell ),
449+ }
416450
417451 tibiaDataRequestHandler (
418452 c ,
453+ tibiadataRequest ,
419454 func (BoxContentHTML string ) (interface {}, int ) {
420455 return TibiaSpellsSpellV3Impl (spell , BoxContentHTML ), http .StatusOK
421456 },
422457 "TibiaSpellsSpellV3" )
423458}
424459
425460func tibiaWorldsOverviewV3 (c * gin.Context ) {
426- // Getting data with TibiadataHTMLDataCollectorV3
427- TibiadataRequest .URL = "https://www.tibia.com/community/?subtopic=worlds"
461+ tibiadataRequest := TibiadataRequestStruct {
462+ Method : resty .MethodGet ,
463+ URL : "https://www.tibia.com/community/?subtopic=worlds" ,
464+ }
428465
429466 tibiaDataRequestHandler (
430467 c ,
468+ tibiadataRequest ,
431469 func (BoxContentHTML string ) (interface {}, int ) {
432470 return TibiaWorldsOverviewV3Impl (BoxContentHTML ), http .StatusOK
433471 },
@@ -441,19 +479,22 @@ func tibiaWorldsWorldV3(c *gin.Context) {
441479 // Adding fix for First letter to be upper and rest lower
442480 world = TibiadataStringWorldFormatToTitleV3 (world )
443481
444- // Getting data with TibiadataHTMLDataCollectorV3
445- TibiadataRequest .URL = "https://www.tibia.com/community/?subtopic=worlds&world=" + TibiadataQueryEscapeStringV3 (world )
482+ tibiadataRequest := TibiadataRequestStruct {
483+ Method : resty .MethodGet ,
484+ URL : "https://www.tibia.com/community/?subtopic=worlds&world=" + TibiadataQueryEscapeStringV3 (world ),
485+ }
446486
447487 tibiaDataRequestHandler (
448488 c ,
489+ tibiadataRequest ,
449490 func (BoxContentHTML string ) (interface {}, int ) {
450491 return TibiaWorldsWorldV3Impl (world , BoxContentHTML ), http .StatusOK
451492 },
452493 "TibiaWorldsWorldV3" )
453494}
454495
455- func tibiaDataRequestHandler (c * gin.Context , requestHandler func (string ) (interface {}, int ), handlerName string ) {
456- BoxContentHTML , err := TibiadataHTMLDataCollectorV3 (TibiadataRequest )
496+ func tibiaDataRequestHandler (c * gin.Context , tibiaDataRequest TibiadataRequestStruct , requestHandler func (string ) (interface {}, int ), handlerName string ) {
497+ BoxContentHTML , err := TibiadataHTMLDataCollectorV3 (tibiaDataRequest )
457498
458499 // return error (e.g. for maintenance mode)
459500 if err != nil {
0 commit comments