Skip to content

Commit

Permalink
add versioning api - close #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Polyakov committed Jun 19, 2024
1 parent 37f6248 commit a047df1
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 156 deletions.
22 changes: 11 additions & 11 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ paths:
'500':
description: Internal Server Error
parameters: []
/api/users:
/api/v1/users:
get:
tags:
- Users
Expand Down Expand Up @@ -132,7 +132,7 @@ paths:
description: Bad request
'500':
description: Failed response
'/api/users/{id}':
'/api/v1/users/{id}':
get:
tags:
- Users
Expand Down Expand Up @@ -204,7 +204,7 @@ paths:
content:
application/json:
schema: {}
/api/games:
/api/v1/games:
get:
tags:
- Games
Expand Down Expand Up @@ -242,7 +242,7 @@ paths:
description: Bad request
'500':
description: Failed response
'/api/games/{id}':
'/api/v1/games/{id}':
get:
tags:
- Games
Expand Down Expand Up @@ -319,7 +319,7 @@ paths:
description: Bad request
'500':
description: Failed response
/api/teams:
/api/v1/teams:
get:
tags:
- Teams
Expand Down Expand Up @@ -371,7 +371,7 @@ paths:
content:
application/json:
schema: {}
'/api/teams/{id}':
'/api/v1/teams/{id}':
get:
tags:
- Teams
Expand Down Expand Up @@ -430,7 +430,7 @@ paths:
responses:
'200':
description: Team deleted successfully
/api/results:
/api/v1/results:
get:
tags:
- Results
Expand Down Expand Up @@ -462,7 +462,7 @@ paths:
responses:
'200':
description: Result created successfully
'/api/results/{id}':
'/api/v1/results/{id}':
get:
tags:
- Results
Expand All @@ -483,7 +483,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ResultResponse'
/api/services:
/api/v1/services:
get:
tags:
- Services
Expand Down Expand Up @@ -515,7 +515,7 @@ paths:
responses:
'200':
description: Service created successfully
'/api/services/{id}':
'/api/v1/services/{id}':
get:
tags:
- Services
Expand Down Expand Up @@ -574,7 +574,7 @@ paths:
responses:
'200':
description: Service deleted successfully
/api/universities:
/api/v1/universities:
get:
summary: Retrieves a list of universities
description: >
Expand Down
10 changes: 5 additions & 5 deletions html/assets/js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ if(!window.ctf01d_tp_api) window.ctf01d_tp_api = {};

window.ctf01d_tp_api.games_list = function() {
return $.ajax({
url: '/api/games',
url: '/api/v1/games',
method: 'GET',
});
}

window.ctf01d_tp_api.game_info = function(game_id) {
return $.ajax({
url: '/api/games/' + game_id,
url: '/api/v1/games/' + game_id,
method: 'GET',
});
}

window.ctf01d_tp_api.game_create = function(game_data) {
return $.ajax({
url: '/api/games',
url: '/api/v1/games',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify(game_data),
Expand All @@ -26,7 +26,7 @@ window.ctf01d_tp_api.game_create = function(game_data) {

window.ctf01d_tp_api.auth_signin = function(auth_data) {
return $.ajax({
url: '/api/login',
url: '/api/v1/auth/signin',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify(auth_data),
Expand All @@ -35,7 +35,7 @@ window.ctf01d_tp_api.auth_signin = function(auth_data) {

window.ctf01d_tp_api.auth_session = function() {
return $.ajax({
url: '/api/auth/session',
url: '/api/v1/auth/session',
method: 'GET',
contentType: 'application/json',
});
Expand Down
4 changes: 2 additions & 2 deletions internal/app/handlers/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ func (siw *ServerInterfaceWrapper) UpdateTeam(w http.ResponseWriter, r *http.Req
siw.handlers.UpdateTeam(w, r, id)
}

func (siw *ServerInterfaceWrapper) GetApiUniversities(w http.ResponseWriter, r *http.Request, params server.GetApiUniversitiesParams) {
siw.handlers.GetApiUniversities(w, r, params)
func (siw *ServerInterfaceWrapper) GetApiV1Universities(w http.ResponseWriter, r *http.Request, params server.GetApiV1UniversitiesParams) {
siw.handlers.GetApiV1Universities(w, r, params)
}

func (siw *ServerInterfaceWrapper) ListUsers(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion internal/app/handlers/universities.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"ctf01d/internal/app/view"
)

func (h *Handlers) GetApiUniversities(w http.ResponseWriter, r *http.Request, params server.GetApiUniversitiesParams) {
func (h *Handlers) GetApiV1Universities(w http.ResponseWriter, r *http.Request, params server.GetApiV1UniversitiesParams) {
queryParam := r.URL.Query().Get("term")

repo := repository.NewUniversityRepository(h.DB)
Expand Down
Loading

0 comments on commit a047df1

Please sign in to comment.