forked from vieter-v/vieter
Started work on better repos cli
This commit is contained in:
parent
d7f6c87053
commit
f44ce1c17f
5 changed files with 41 additions and 33 deletions
|
|
@ -4,6 +4,7 @@ import web
|
|||
import git
|
||||
import net.http
|
||||
import rand
|
||||
import response { new_response, new_data_response }
|
||||
|
||||
const repos_file = 'repos.json'
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ fn (mut app App) get_repos() web.Result {
|
|||
|
||||
repos := rlock app.git_mutex {
|
||||
git.read_repos(app.conf.repos_file) or {
|
||||
app.lerror('Failed to read repos file.')
|
||||
app.lerror('Failed to read repos file: $err.msg')
|
||||
|
||||
return app.status(http.Status.internal_server_error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
module server
|
||||
|
||||
struct Response<T> {
|
||||
message string
|
||||
data T
|
||||
}
|
||||
|
||||
fn new_response(message string) Response<string> {
|
||||
return Response<string>{
|
||||
message: message
|
||||
data: ''
|
||||
}
|
||||
}
|
||||
|
||||
fn new_data_response<T>(data T) Response<T> {
|
||||
return Response<T>{
|
||||
message: ''
|
||||
data: data
|
||||
}
|
||||
}
|
||||
|
||||
fn new_full_response<T>(message string, data T) Response<T> {
|
||||
return Response<T>{
|
||||
message: message
|
||||
data: data
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import time
|
|||
import rand
|
||||
import util
|
||||
import net.http
|
||||
import response { new_response, new_data_response }
|
||||
|
||||
// healthcheck just returns a string, but can be used to quickly check if the
|
||||
// server is still responsive.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue