aboutsummaryrefslogtreecommitdiff
path: root/routers/api/v1/repo/file.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-06-03 07:26:09 -0400
committerUnknwon <u@gogs.io>2017-06-03 07:26:09 -0400
commit2478b874320ed91d4424dea42a40aacbd2b1ce1c (patch)
treedbaf2a482ffc43b5013aa08c83c686698ab181c1 /routers/api/v1/repo/file.go
parente33c714073cc65f814bacf604a84cd2741951afa (diff)
Refactoring: rename ctx -> c
Diffstat (limited to 'routers/api/v1/repo/file.go')
-rw-r--r--routers/api/v1/repo/file.go44
1 files changed, 22 insertions, 22 deletions
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index 81c399f6..df6a4857 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -13,60 +13,60 @@ import (
)
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content
-func GetRawFile(ctx *context.APIContext) {
- if !ctx.Repo.HasAccess() {
- ctx.Status(404)
+func GetRawFile(c *context.APIContext) {
+ if !c.Repo.HasAccess() {
+ c.Status(404)
return
}
- if ctx.Repo.Repository.IsBare {
- ctx.Status(404)
+ if c.Repo.Repository.IsBare {
+ c.Status(404)
return
}
- blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath)
+ blob, err := c.Repo.Commit.GetBlobByPath(c.Repo.TreePath)
if err != nil {
if git.IsErrNotExist(err) {
- ctx.Status(404)
+ c.Status(404)
} else {
- ctx.Error(500, "GetBlobByPath", err)
+ c.Error(500, "GetBlobByPath", err)
}
return
}
- if err = repo.ServeBlob(ctx.Context, blob); err != nil {
- ctx.Error(500, "ServeBlob", err)
+ if err = repo.ServeBlob(c.Context, blob); err != nil {
+ c.Error(500, "ServeBlob", err)
}
}
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive
-func GetArchive(ctx *context.APIContext) {
- repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame"))
+func GetArchive(c *context.APIContext) {
+ repoPath := models.RepoPath(c.Params(":username"), c.Params(":reponame"))
gitRepo, err := git.OpenRepository(repoPath)
if err != nil {
- ctx.Error(500, "OpenRepository", err)
+ c.Error(500, "OpenRepository", err)
return
}
- ctx.Repo.GitRepo = gitRepo
+ c.Repo.GitRepo = gitRepo
- repo.Download(ctx.Context)
+ repo.Download(c.Context)
}
-func GetEditorconfig(ctx *context.APIContext) {
- ec, err := ctx.Repo.GetEditorconfig()
+func GetEditorconfig(c *context.APIContext) {
+ ec, err := c.Repo.GetEditorconfig()
if err != nil {
if git.IsErrNotExist(err) {
- ctx.Error(404, "GetEditorconfig", err)
+ c.Error(404, "GetEditorconfig", err)
} else {
- ctx.Error(500, "GetEditorconfig", err)
+ c.Error(500, "GetEditorconfig", err)
}
return
}
- fileName := ctx.Params("filename")
+ fileName := c.Params("filename")
def := ec.GetDefinitionForFilename(fileName)
if def == nil {
- ctx.Error(404, "GetDefinitionForFilename", err)
+ c.Error(404, "GetDefinitionForFilename", err)
return
}
- ctx.JSON(200, def)
+ c.JSON(200, def)
}