Skip to content

Commit 42d66dd

Browse files
authored
Adjustment of endpoint namings (#74)
1 parent c3d5b0f commit 42d66dd

File tree

2 files changed

+58
-62
lines changed

2 files changed

+58
-62
lines changed

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,25 @@ Those are the current existing endpoints.
9797

9898
- GET `/ping`
9999
- GET `/health`
100-
- GET `/v3/characters/character/:character`
100+
- GET `/v3/character/:name`
101+
- GET `/v3/creature/:race`
101102
- GET `/v3/creatures`
102-
- GET `/v3/creatures/creature/:creature`
103103
- GET `/v3/fansites`
104-
- GET `/v3/guilds/guild/:guild`
105-
- GET `/v3/guilds/world/:world`
106-
- GET `/v3/highscores/world/:world`
107-
- GET `/v3/highscores/world/:world/:category`
108-
- GET `/v3/highscores/world/:world/:category/:vocation`
109-
- GET `/v3/houses/world/:world/house/:houseid`
110-
- GET `/v3/houses/world/:world/town/:town`
111-
- GET `/v3/killstatistics/world/:world`
104+
- GET `/v3/guild/:name`
105+
- GET `/v3/guilds/:world`
106+
- GET `/v3/highscores/:world/:category/:vocation`
107+
- GET `/v3/house/:world/:house_id`
108+
- GET `/v3/houses/:world/:town`
109+
- GET `/v3/killstatistics/:world`
112110
- GET `/v3/news/archive`
113111
- GET `/v3/news/archive/:days`
114112
- GET `/v3/news/id/:news_id`
115113
- GET `/v3/news/latest`
116114
- GET `/v3/news/newsticker`
115+
- GET `/v3/spell/:spell_id`
117116
- GET `/v3/spells`
118-
- GET `/v3/spells/spell/:spell`
119-
- GET `/v3/spells/vocation/:vocation`
117+
- GET `/v3/world/:name`
120118
- GET `/v3/worlds`
121-
- GET `/v3/worlds/world/:world`
122119
- GET `/versions`
123120

124121
## General information

src/webserver.go

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -83,36 +83,36 @@ func runWebServer() {
8383
v3 := router.Group("/v3")
8484
{
8585
// Tibia characters
86-
v3.GET("/characters/character/:character", tibiaCharactersCharacterV3)
86+
v3.GET("/character/:name", tibiaCharactersCharacterV3)
8787

8888
// Tibia creatures
89+
v3.GET("/creature/:race", tibiaCreaturesCreatureV3)
8990
v3.GET("/creatures", tibiaCreaturesOverviewV3)
90-
v3.GET("/creatures/creature/:race", tibiaCreaturesCreatureV3)
9191

9292
// Tibia fansites
9393
v3.GET("/fansites", tibiaFansitesV3)
9494

9595
// Tibia guilds
96-
v3.GET("/guilds/guild/:guild", tibiaGuildsGuildV3)
97-
//v3.GET("/guilds/guild/:guild/events",TibiaGuildsGuildEventsV3)
98-
//v3.GET("/guilds/guild/:guild/wars",TibiaGuildsGuildWarsV3)
99-
v3.GET("/guilds/world/:world", tibiaGuildsOverviewV3)
96+
v3.GET("/guild/:name", tibiaGuildsGuildV3)
97+
//v3.GET("/guild/:name/events",TibiaGuildsGuildEventsV3)
98+
//v3.GET("/guild/:name/wars",TibiaGuildsGuildWarsV3)
99+
v3.GET("/guilds/:world", tibiaGuildsOverviewV3)
100100

101101
// Tibia highscores
102-
v3.GET("/highscores/world/:world", func(c *gin.Context) {
103-
c.Redirect(http.StatusMovedPermanently, v3.BasePath()+"/highscores/world/"+c.Param("world")+"/experience/"+TibiadataDefaultVoc)
102+
v3.GET("/highscores/:world", func(c *gin.Context) {
103+
c.Redirect(http.StatusMovedPermanently, v3.BasePath()+"/highscores/"+c.Param("world")+"/experience/"+TibiadataDefaultVoc)
104104
})
105-
v3.GET("/highscores/world/:world/:category", func(c *gin.Context) {
106-
c.Redirect(http.StatusMovedPermanently, v3.BasePath()+"/highscores/world/"+c.Param("world")+"/"+c.Param("category")+"/"+TibiadataDefaultVoc)
105+
v3.GET("/highscores/:world/:category", func(c *gin.Context) {
106+
c.Redirect(http.StatusMovedPermanently, v3.BasePath()+"/highscores/"+c.Param("world")+"/"+c.Param("category")+"/"+TibiadataDefaultVoc)
107107
})
108-
v3.GET("/highscores/world/:world/:category/:vocation", tibiaHighscoresV3)
108+
v3.GET("/highscores/:world/:category/:vocation", tibiaHighscoresV3)
109109

110110
// Tibia houses
111-
v3.GET("/houses/world/:world/house/:houseid", tibiaHousesHouseV3)
112-
v3.GET("/houses/world/:world/town/:town", tibiaHousesOverviewV3)
111+
v3.GET("/house/:world/:house_id", tibiaHousesHouseV3)
112+
v3.GET("/houses/:world/:town", tibiaHousesOverviewV3)
113113

114114
// Tibia killstatistics
115-
v3.GET("/killstatistics/world/:world", tibiaKillstatisticsV3)
115+
v3.GET("/killstatistics/:world", tibiaKillstatisticsV3)
116116

117117
// Tibia news
118118
v3.GET("/news/archive", tibiaNewslistV3) // all categories (default 90 days)
@@ -122,13 +122,12 @@ func runWebServer() {
122122
v3.GET("/news/newsticker", tibiaNewslistV3) // only news_ticker
123123

124124
// Tibia spells
125+
v3.GET("/spell/:spell_id", tibiaSpellsSpellV3)
125126
v3.GET("/spells", tibiaSpellsOverviewV3)
126-
v3.GET("/spells/spell/:spell", tibiaSpellsSpellV3)
127-
v3.GET("/spells/vocation/:vocation", tibiaSpellsOverviewV3)
128127

129128
// Tibia worlds
129+
v3.GET("/world/:name", tibiaWorldsWorldV3)
130130
v3.GET("/worlds", tibiaWorldsOverviewV3)
131-
v3.GET("/worlds/world/:world", tibiaWorldsWorldV3)
132131
}
133132

134133
// container version details endpoint
@@ -176,16 +175,16 @@ func runWebServer() {
176175
// @Tags characters
177176
// @Accept json
178177
// @Produce json
179-
// @Param character path string true "The character name"
178+
// @Param name path string true "The character name" extensions(x-example=Trollefar)
180179
// @Success 200 {object} CharacterResponse
181-
// @Router /v3/characters/character/{character} [get]
180+
// @Router /v3/character/{name} [get]
182181
func tibiaCharactersCharacterV3(c *gin.Context) {
183182
// getting params from URL
184-
character := c.Param("character")
183+
name := c.Param("name")
185184

186185
tibiadataRequest := TibiadataRequestStruct{
187186
Method: resty.MethodGet,
188-
URL: "https://www.tibia.com/community/?subtopic=characters&name=" + TibiadataQueryEscapeStringV3(character),
187+
URL: "https://www.tibia.com/community/?subtopic=characters&name=" + TibiadataQueryEscapeStringV3(name),
189188
}
190189

191190
tibiaDataRequestHandler(
@@ -226,9 +225,9 @@ func tibiaCreaturesOverviewV3(c *gin.Context) {
226225
// @Tags creatures
227226
// @Accept json
228227
// @Produce json
229-
// @Param race path string true "The race of creature"
228+
// @Param race path string true "The race of creature" extensions(x-example=nightmare)
230229
// @Success 200 {object} CreatureResponse
231-
// @Router /v3/creatures/creature/{race} [get]
230+
// @Router /v3/creature/{race} [get]
232231
func tibiaCreaturesCreatureV3(c *gin.Context) {
233232
// getting params from URL
234233
race := c.Param("race")
@@ -276,12 +275,12 @@ func tibiaFansitesV3(c *gin.Context) {
276275
// @Tags guilds
277276
// @Accept json
278277
// @Produce json
279-
// @Param guild path string true "The name of guild"
278+
// @Param name path string true "The name of guild" extensions(x-example=Elysium)
280279
// @Success 200 {object} GuildResponse
281-
// @Router /v3/guilds/guild/{guild} [get]
280+
// @Router /v3/guild/{name} [get]
282281
func tibiaGuildsGuildV3(c *gin.Context) {
283282
// getting params from URL
284-
guild := c.Param("guild")
283+
guild := c.Param("name")
285284

286285
tibiadataRequest := TibiadataRequestStruct{
287286
Method: resty.MethodGet,
@@ -303,9 +302,9 @@ func tibiaGuildsGuildV3(c *gin.Context) {
303302
// @Tags guilds
304303
// @Accept json
305304
// @Produce json
306-
// @Param world path string true "The world"
305+
// @Param world path string true "The world" extensions(x-example=Antica)
307306
// @Success 200 {object} GuildsOverviewResponse
308-
// @Router /v3/guilds/world/{world} [get]
307+
// @Router /v3/guilds/{world} [get]
309308
func tibiaGuildsOverviewV3(c *gin.Context) {
310309
// getting params from URL
311310
world := c.Param("world")
@@ -333,11 +332,11 @@ func tibiaGuildsOverviewV3(c *gin.Context) {
333332
// @Tags highscores
334333
// @Accept json
335334
// @Produce json
336-
// @Param world path string true "The world (default: all)"
337-
// @Param category path string true "The category (default: experience)"
338-
// @Param vocation path string true "The vocation (default: all)"
335+
// @Param world path string true "The world" default(all) extensions(x-example=Antica)
336+
// @Param category path string true "The category" default(experience) Enums(achievements, axefighting, charmpoints, clubfighting, distancefighting, experience, fishing, fistfighting, goshnarstaint, loyaltypoints, magiclevel, shielding, swordfighting, dromescore) extensions(x-example=fishing)
337+
// @Param vocation path string true "The vocation" default(all) Enums(all, knights, paladins, sorcerers, druids) extensions(x-example=knights)
339338
// @Success 200 {object} HighscoresResponse
340-
// @Router /v3/highscores/world/{world}/{category}/{vocation} [get]
339+
// @Router /v3/highscores/{world}/{category}/{vocation} [get]
341340
func tibiaHighscoresV3(c *gin.Context) {
342341
// getting params from URL
343342
world := c.Param("world")
@@ -378,14 +377,14 @@ func tibiaHighscoresV3(c *gin.Context) {
378377
// @Tags houses
379378
// @Accept json
380379
// @Produce json
381-
// @Param world path string true "The world to show"
382-
// @Param houseid path int true "The ID of the house"
380+
// @Param world path string true "The world to show" extensions(x-example=Antica)
381+
// @Param house_id path int true "The ID of the house" extensions(x-example=35019)
383382
// @Success 200 {object} HouseResponse
384-
// @Router /v3/houses/world/{world}/house/{houseid} [get]
383+
// @Router /v3/house/{world}/{house_id} [get]
385384
func tibiaHousesHouseV3(c *gin.Context) {
386385
// getting params from URL
387386
world := c.Param("world")
388-
houseid := c.Param("houseid")
387+
houseid := c.Param("house_id")
389388

390389
// Adding fix for First letter to be upper and rest lower
391390
world = TibiadataStringWorldFormatToTitleV3(world)
@@ -410,10 +409,10 @@ func tibiaHousesHouseV3(c *gin.Context) {
410409
// @Tags houses
411410
// @Accept json
412411
// @Produce json
413-
// @Param world path string true "The world to show"
414-
// @Param town path string true "The town to show"
412+
// @Param world path string true "The world to show" extensions(x-example=Antica)
413+
// @Param town path string true "The town to show" extensions(x-example=Venore)
415414
// @Success 200 {object} HousesOverviewResponse
416-
// @Router /v3/houses/world/{world}/town/{town} [get]
415+
// @Router /v3/houses/{world}/{town} [get]
417416
//TODO: This API needs to be refactored somehow to use tibiaDataRequestHandler
418417
func tibiaHousesOverviewV3(c *gin.Context) {
419418
// getting params from URL
@@ -436,9 +435,9 @@ func tibiaHousesOverviewV3(c *gin.Context) {
436435
// @Tags killstatistics
437436
// @Accept json
438437
// @Produce json
439-
// @Param world path string true "The world to show"
438+
// @Param world path string true "The world to show" extensions(x-example=Antica)
440439
// @Success 200 {object} KillStatisticsResponse
441-
// @Router /v3/killstatistics/world/{world} [get]
440+
// @Router /v3/killstatistics/{world} [get]
442441
func tibiaKillstatisticsV3(c *gin.Context) {
443442
// getting params from URL
444443
world := c.Param("world")
@@ -479,7 +478,7 @@ func tibiaNewslistArchiveV3() bool {
479478
// @Tags news
480479
// @Accept json
481480
// @Produce json
482-
// @Param days path int true "The number of days to show"
481+
// @Param days path int true "The number of days to show" default(90) minimum(1) extensions(x-example=30)
483482
// @Success 200 {object} NewsListResponse
484483
// @Router /v3/news/archive/{days} [get]
485484
func tibiaNewslistArchiveDaysV3() bool {
@@ -567,7 +566,7 @@ func tibiaNewslistV3(c *gin.Context) {
567566
// @Tags news
568567
// @Accept json
569568
// @Produce json
570-
// @Param news_id path int true "The ID of news entry"
569+
// @Param news_id path int true "The ID of news entry" extensions(x-example=6512)
571570
// @Success 200 {object} NewsResponse
572571
// @Router /v3/news/id/{news_id} [get]
573572
func tibiaNewsV3(c *gin.Context) {
@@ -640,12 +639,12 @@ func tibiaSpellsOverviewV3(c *gin.Context) {
640639
// @Tags spells
641640
// @Accept json
642641
// @Produce json
643-
// @Param spell path string true "The name of spell"
642+
// @Param spell_id path string true "The name of spell" extensions(x-example=stronghaste)
644643
// @Success 200 {object} SpellInformationResponse
645-
// @Router /v3/spells/spell/{spell} [get]
644+
// @Router /v3/spell/{spell_id} [get]
646645
func tibiaSpellsSpellV3(c *gin.Context) {
647646
// getting params from URL
648-
spell := c.Param("spell")
647+
spell := c.Param("spell_id")
649648

650649
tibiadataRequest := TibiadataRequestStruct{
651650
Method: resty.MethodGet,
@@ -690,12 +689,12 @@ func tibiaWorldsOverviewV3(c *gin.Context) {
690689
// @Tags worlds
691690
// @Accept json
692691
// @Produce json
693-
// @Param world path string true "The name of world"
692+
// @Param name path string true "The name of world" extensions(x-example=Antica)
694693
// @Success 200 {object} WorldResponse
695-
// @Router /v3/worlds/world/{world} [get]
694+
// @Router /v3/world/{name} [get]
696695
func tibiaWorldsWorldV3(c *gin.Context) {
697696
// getting params from URL
698-
world := c.Param("world")
697+
world := c.Param("name")
699698

700699
// Adding fix for First letter to be upper and rest lower
701700
world = TibiadataStringWorldFormatToTitleV3(world)

0 commit comments

Comments
 (0)