From 9ac46fb983f31cfece76e2181a9fe73b71f02e2e Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Tue, 30 Aug 2016 20:18:40 -0300 Subject: Support Editorconfig on web editor --- routers/api/v1/repo/file.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'routers/api/v1/repo/file.go') 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) +} -- cgit v1.2.3