forked from vlang/gitly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.v
28 lines (25 loc) · 863 Bytes
/
api.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2020 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by a GPL license that can be found in the LICENSE file.
module main
import vweb
import json
['/api/:user/:repo/issues']
pub fn (mut app App) api_issues(user string, repo string) vweb.Result {
if !app.exists_user_repo(user, repo) {
return app.json('{}')
}
issues := app.find_repo_issues(app.repo.id)
// return app.json(json.encode(issues)) // TODO bring this back once autofree bug is fixed
js := json.encode(issues)
return app.json(js)
}
['/api/:user/:repo/commits']
pub fn (mut app App) api_commits(user string, repo string) vweb.Result {
if !app.exists_user_repo(user, repo) {
return app.json('{}')
}
commits := app.find_repo_commits(app.repo.id)
// return app.json(json.encode(commits))
js := json.encode(commits)
return app.json(js)
}