summaryrefslogtreecommitdiffstats
path: root/routers/web/swagger_json.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-02-18 17:52:02 +0800
committerGitHub <noreply@github.com>2024-02-18 10:52:02 +0100
commit31bb9f3247388b993c61a10190cfd512408ce57e (patch)
tree6a4c777d5507b8e92cebd1786750c6a4db9367c8 /routers/web/swagger_json.go
parenta784ed3d6c6946fd9bf95f2e910f52f549326fe2 (diff)
downloadgitea-31bb9f3247388b993c61a10190cfd512408ce57e.tar.gz
gitea-31bb9f3247388b993c61a10190cfd512408ce57e.zip
Refactor more code in templates (#29236)
Follow #29165. * Introduce JSONTemplate to help to render JSON templates * Introduce JSEscapeSafe for templates. Now only use `{{ ... | JSEscape}}` instead of `{{ ... | JSEscape | Safe}}` * Simplify "UserLocationMapURL" useage
Diffstat (limited to 'routers/web/swagger_json.go')
-rw-r--r--routers/web/swagger_json.go14
1 files changed, 1 insertions, 13 deletions
diff --git a/routers/web/swagger_json.go b/routers/web/swagger_json.go
index 493c97aa67..42e9dbe967 100644
--- a/routers/web/swagger_json.go
+++ b/routers/web/swagger_json.go
@@ -4,22 +4,10 @@
package web
import (
- "code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
)
-// tplSwaggerV1Json swagger v1 json template
-const tplSwaggerV1Json base.TplName = "swagger/v1_json"
-
// SwaggerV1Json render swagger v1 json
func SwaggerV1Json(ctx *context.Context) {
- t, err := ctx.Render.TemplateLookup(string(tplSwaggerV1Json), nil)
- if err != nil {
- ctx.ServerError("unable to find template", err)
- return
- }
- ctx.Resp.Header().Set("Content-Type", "application/json")
- if err = t.Execute(ctx.Resp, ctx.Data); err != nil {
- ctx.ServerError("unable to execute template", err)
- }
+ ctx.JSONTemplate("swagger/v1_json")
}