diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2017-03-03 22:35:42 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-03-03 22:35:42 +0800 |
commit | d76d67de234df06dc4742a7d0d2d60070fb32fba (patch) | |
tree | 9a96b915ba13b6064e7c46fbaaf47ed4dac9a58f /models/issue.go | |
parent | 0afab876311a35c56a23b1f7903f9247d5673c8a (diff) | |
download | gitea-d76d67de234df06dc4742a7d0d2d60070fb32fba.tar.gz gitea-d76d67de234df06dc4742a7d0d2d60070fb32fba.zip |
feat: expose url field on issue api. (#982)
* Add api url func.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* fix: Add unit testing.
* fix: conflicts
* fix: remove trim
* fix: revert test function name.
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/models/issue.go b/models/issue.go index ca01ffe2fa..c740d8fec4 100644 --- a/models/issue.go +++ b/models/issue.go @@ -7,6 +7,7 @@ package models import ( "errors" "fmt" + "path" "sort" "strings" "time" @@ -200,6 +201,11 @@ func (issue *Issue) GetIsRead(userID int64) error { return nil } +// APIURL returns the absolute APIURL to this issue. +func (issue *Issue) APIURL() string { + return issue.Repo.APIURL() + "/" + path.Join("issues", fmt.Sprint(issue.ID)) +} + // HTMLURL returns the absolute URL to this issue. func (issue *Issue) HTMLURL() string { var path string @@ -246,6 +252,7 @@ func (issue *Issue) APIFormat() *api.Issue { apiIssue := &api.Issue{ ID: issue.ID, + URL: issue.APIURL(), Index: issue.Index, Poster: issue.Poster.APIFormat(), Title: issue.Title, |