forked from vieter-v/vieter
feat(server): moved api routes under /v1 namespace
This commit is contained in:
parent
3a5ac5d32b
commit
6b79f7b5ed
5 changed files with 41 additions and 37 deletions
|
|
@ -6,9 +6,9 @@ import response { new_data_response, new_response }
|
|||
import db
|
||||
import models { GitRepo, GitRepoArch, GitRepoFilter }
|
||||
|
||||
// get_repos returns the current list of repos.
|
||||
['/api/repos'; get]
|
||||
fn (mut app App) get_repos() web.Result {
|
||||
// v1_get_repos returns the current list of repos.
|
||||
['/api/v1/repos'; get]
|
||||
fn (mut app App) v1_get_repos() web.Result {
|
||||
if !app.is_authorized() {
|
||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||
}
|
||||
|
|
@ -21,9 +21,9 @@ fn (mut app App) get_repos() web.Result {
|
|||
return app.json(http.Status.ok, new_data_response(repos))
|
||||
}
|
||||
|
||||
// get_single_repo returns the information for a single repo.
|
||||
['/api/repos/:id'; get]
|
||||
fn (mut app App) get_single_repo(id int) web.Result {
|
||||
// v1_get_single_repo returns the information for a single repo.
|
||||
['/api/v1/repos/:id'; get]
|
||||
fn (mut app App) v1_get_single_repo(id int) web.Result {
|
||||
if !app.is_authorized() {
|
||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||
}
|
||||
|
|
@ -33,9 +33,9 @@ fn (mut app App) get_single_repo(id int) web.Result {
|
|||
return app.json(http.Status.ok, new_data_response(repo))
|
||||
}
|
||||
|
||||
// post_repo creates a new repo from the provided query string.
|
||||
['/api/repos'; post]
|
||||
fn (mut app App) post_repo() web.Result {
|
||||
// v1_post_repo creates a new repo from the provided query string.
|
||||
['/api/v1/repos'; post]
|
||||
fn (mut app App) v1_post_repo() web.Result {
|
||||
if !app.is_authorized() {
|
||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||
}
|
||||
|
|
@ -57,9 +57,9 @@ fn (mut app App) post_repo() web.Result {
|
|||
return app.json(http.Status.ok, new_response('Repo added successfully.'))
|
||||
}
|
||||
|
||||
// delete_repo removes a given repo from the server's list.
|
||||
['/api/repos/:id'; delete]
|
||||
fn (mut app App) delete_repo(id int) web.Result {
|
||||
// v1_delete_repo removes a given repo from the server's list.
|
||||
['/api/v1/repos/:id'; delete]
|
||||
fn (mut app App) v1_delete_repo(id int) web.Result {
|
||||
if !app.is_authorized() {
|
||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||
}
|
||||
|
|
@ -69,9 +69,9 @@ fn (mut app App) delete_repo(id int) web.Result {
|
|||
return app.json(http.Status.ok, new_response('Repo removed successfully.'))
|
||||
}
|
||||
|
||||
// patch_repo updates a repo's data with the given query params.
|
||||
['/api/repos/:id'; patch]
|
||||
fn (mut app App) patch_repo(id int) web.Result {
|
||||
// v1_patch_repo updates a repo's data with the given query params.
|
||||
['/api/v1/repos/:id'; patch]
|
||||
fn (mut app App) v1_patch_repo(id int) web.Result {
|
||||
if !app.is_authorized() {
|
||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ import os
|
|||
import util
|
||||
import models { BuildLog, BuildLogFilter }
|
||||
|
||||
// get_logs returns all build logs in the database. A 'repo' query param can
|
||||
// v1_get_logs returns all build logs in the database. A 'repo' query param can
|
||||
// optionally be added to limit the list of build logs to that repository.
|
||||
['/api/logs'; get]
|
||||
fn (mut app App) get_logs() web.Result {
|
||||
['/api/v1/logs'; get]
|
||||
fn (mut app App) v1_get_logs() web.Result {
|
||||
if !app.is_authorized() {
|
||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||
}
|
||||
|
|
@ -26,9 +26,9 @@ fn (mut app App) get_logs() web.Result {
|
|||
return app.json(http.Status.ok, new_data_response(logs))
|
||||
}
|
||||
|
||||
// get_single_log returns the build log with the given id.
|
||||
['/api/logs/:id'; get]
|
||||
fn (mut app App) get_single_log(id int) web.Result {
|
||||
// v1_get_single_log returns the build log with the given id.
|
||||
['/api/v1/logs/:id'; get]
|
||||
fn (mut app App) v1_get_single_log(id int) web.Result {
|
||||
if !app.is_authorized() {
|
||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||
}
|
||||
|
|
@ -38,9 +38,9 @@ fn (mut app App) get_single_log(id int) web.Result {
|
|||
return app.json(http.Status.ok, new_data_response(log))
|
||||
}
|
||||
|
||||
// get_log_content returns the actual build log file for the given id.
|
||||
['/api/logs/:id/content'; get]
|
||||
fn (mut app App) get_log_content(id int) web.Result {
|
||||
// v1_get_log_content returns the actual build log file for the given id.
|
||||
['/api/v1/logs/:id/content'; get]
|
||||
fn (mut app App) v1_get_log_content(id int) web.Result {
|
||||
if !app.is_authorized() {
|
||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||
}
|
||||
|
|
@ -62,9 +62,9 @@ fn parse_query_time(query string) ?time.Time {
|
|||
return t
|
||||
}
|
||||
|
||||
// post_log adds a new log to the database.
|
||||
['/api/logs'; post]
|
||||
fn (mut app App) post_log() web.Result {
|
||||
// v1_post_log adds a new log to the database.
|
||||
['/api/v1/logs'; post]
|
||||
fn (mut app App) v1_post_log() web.Result {
|
||||
if !app.is_authorized() {
|
||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue