diff --git a/routers/hat/hat.go b/routers/hat/hat.go index 539d108..115e0aa 100644 --- a/routers/hat/hat.go +++ b/routers/hat/hat.go @@ -79,6 +79,7 @@ func Routers(ctx gocontext.Context) *web.Route { }, context.ReferencesGitRepo(), reqRepoReader(unit.TypeCode)) m.Group("/tags", func() { m.Get("", repo.ListTags) + m.Get("/*", repo.GetTag) }, reqRepoReader(unit_model.TypeCode), context.ReferencesGitRepo(true)) m.Group("/wikies", func() { m.Combo("").Get(repo.ListWikiPages). diff --git a/routers/hat/repo/tag.go b/routers/hat/repo/tag.go index a0a88dd..260d4a0 100644 --- a/routers/hat/repo/tag.go +++ b/routers/hat/repo/tag.go @@ -44,6 +44,20 @@ func ListTags(ctx *context.APIContext) { ctx.JSON(http.StatusOK, &apiTags) } +func GetTag(ctx *context.APIContext) { + tagName := ctx.Params("*") + tag, err := ctx.Repo.GitRepo.GetTag(tagName) + if err != nil { + ctx.NotFound(tagName) + } + + apiTag, err := convert.ToTag(ctx.Repo.Repository, ctx.Repo.GitRepo, tag) + if err != nil { + ctx.Error(http.StatusInternalServerError, "hat_convert.ToTag", err) + } + ctx.JSON(http.StatusOK, apiTag) +} + func BranchTagCount(ctx *context.APIContext) { _, tagsTotal, err := ctx.Repo.GitRepo.GetTagInfos(0, 0) if err != nil {