summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorAndrey Nering <andrey.nering@gmail.com>2016-08-30 20:18:40 -0300
committerAndrey Nering <andrey.nering@gmail.com>2016-08-30 20:30:47 -0300
commit9ac46fb983f31cfece76e2181a9fe73b71f02e2e (patch)
tree6499c69d94fcbeb71c144295c6df1ccc1883f8b9 /routers/api
parent47a3243ff1b3da1b435d9390e578752f3a74ae8e (diff)
downloadgitea-9ac46fb983f31cfece76e2181a9fe73b71f02e2e.tar.gz
gitea-9ac46fb983f31cfece76e2181a9fe73b71f02e2e.zip
Support Editorconfig on web editor
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/api.go1
-rw-r--r--routers/api/v1/repo/file.go20
2 files changed, 21 insertions, 0 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 16322fbffd..0591cddb86 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -290,6 +290,7 @@ func RegisterRoutes(m *macaron.Macaron) {
Patch(reqRepoWriter(), bind(api.EditMilestoneOption{}), repo.EditMilestone).
Delete(reqRepoWriter(), repo.DeleteMilestone)
})
+ m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
}, repoAssignment())
}, reqToken())
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index 972dbefac0..ee9d15a322 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -45,3 +45,23 @@ func GetArchive(ctx *context.APIContext) {
repo.Download(ctx.Context)
}
+
+func GetEditorconfig(ctx *context.APIContext) {
+ ec, err := ctx.Repo.GetEditorconfig()
+ if err != nil {
+ if git.IsErrNotExist(err) {
+ ctx.Error(404, "GetEditorconfig", err)
+ } else {
+ ctx.Error(500, "GetEditorconfig", err)
+ }
+ return
+ }
+
+ fileName := ctx.Params("filename")
+ def := ec.GetDefinitionForFilename(fileName)
+ if def == nil {
+ ctx.Error(404, "GetDefinitionForFilename", err)
+ return
+ }
+ ctx.JSON(200, def)
+}