diff options
author | Unknwon <u@gogs.io> | 2016-03-13 18:49:16 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-03-13 18:49:16 -0400 |
commit | dd6faf7f9bd0a1dbf986e124ea0f4db249e1da48 (patch) | |
tree | 7f9e4107eb961712a56160ef544143eee3771653 /routers/api/v1/repo/file.go | |
parent | db4da7beecd6a8f65bfa264ba18a8cb12303921f (diff) |
Convert all API handers to use *context.APIContext
Diffstat (limited to 'routers/api/v1/repo/file.go')
-rw-r--r-- | routers/api/v1/repo/file.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 7939a584..745b444a 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -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) } |