1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Convert all API handers to use *context.APIContext

This commit is contained in:
Unknwon
2016-03-13 18:49:16 -04:00
parent db4da7beec
commit dd6faf7f9b
20 changed files with 204 additions and 196 deletions

View File

@@ -13,35 +13,35 @@ import (
)
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content
func GetRawFile(ctx *context.Context) {
func GetRawFile(ctx *context.APIContext) {
if !ctx.Repo.HasAccess() {
ctx.Error(404)
ctx.Status(404)
return
}
blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreeName)
if err != nil {
if git.IsErrNotExist(err) {
ctx.Error(404)
ctx.Status(404)
} else {
ctx.APIError(500, "GetBlobByPath", err)
ctx.Error(500, "GetBlobByPath", err)
}
return
}
if err = repo.ServeBlob(ctx, blob); err != nil {
ctx.APIError(500, "ServeBlob", err)
if err = repo.ServeBlob(ctx.Context, blob); err != nil {
ctx.Error(500, "ServeBlob", err)
}
}
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive
func GetArchive(ctx *context.Context) {
func GetArchive(ctx *context.APIContext) {
repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame"))
gitRepo, err := git.OpenRepository(repoPath)
if err != nil {
ctx.APIError(500, "OpenRepository", err)
ctx.Error(500, "OpenRepository", err)
return
}
ctx.Repo.GitRepo = gitRepo
repo.Download(ctx)
repo.Download(ctx.Context)
}