aboutsummaryrefslogtreecommitdiffstats
path: root/modules/templates/dynamic.go
diff options
context:
space:
mode:
authorPiotr Orzechowski <piotr@orzechowski.tech>2018-07-28 02:19:01 +0200
committerLauris BH <lauris@nix.lv>2018-07-28 03:19:01 +0300
commita74426d631e3311cc3c460ae9917f76f0221f4de (patch)
tree1343766d999308825f42bc0b67c1845a5e9e9546 /modules/templates/dynamic.go
parent412583a3f28162c89e827fbb586319ac8eea9825 (diff)
downloadgitea-a74426d631e3311cc3c460ae9917f76f0221f4de.tar.gz
gitea-a74426d631e3311cc3c460ae9917f76f0221f4de.zip
Swagger.v1.json template (#3572)
* Turn swagger.v1.json into template * Rename ENABLE_SWAGGER_ENDPOINT option to ENABLE_SWAGGER
Diffstat (limited to 'modules/templates/dynamic.go')
-rw-r--r--modules/templates/dynamic.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/modules/templates/dynamic.go b/modules/templates/dynamic.go
index c127b69470..d70a465c1c 100644
--- a/modules/templates/dynamic.go
+++ b/modules/templates/dynamic.go
@@ -22,8 +22,8 @@ var (
templates = template.New("")
)
-// Renderer implements the macaron handler for serving the templates.
-func Renderer() macaron.Handler {
+// HTMLRenderer implements the macaron handler for serving HTML templates.
+func HTMLRenderer() macaron.Handler {
return macaron.Renderer(macaron.RenderOptions{
Funcs: NewFuncMap(),
Directory: path.Join(setting.StaticRootPath, "templates"),
@@ -33,6 +33,18 @@ func Renderer() macaron.Handler {
})
}
+// JSONRenderer implements the macaron handler for serving JSON templates.
+func JSONRenderer() macaron.Handler {
+ return macaron.Renderer(macaron.RenderOptions{
+ Funcs: NewFuncMap(),
+ Directory: path.Join(setting.StaticRootPath, "templates"),
+ AppendDirectories: []string{
+ path.Join(setting.CustomPath, "templates"),
+ },
+ HTMLContentType: "application/json",
+ })
+}
+
// Mailer provides the templates required for sending notification mails.
func Mailer() *template.Template {
for _, funcs := range NewFuncMap() {