diff options
author | Piotr Orzechowski <piotr@orzechowski.tech> | 2018-07-28 02:19:01 +0200 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2018-07-28 03:19:01 +0300 |
commit | a74426d631e3311cc3c460ae9917f76f0221f4de (patch) | |
tree | 1343766d999308825f42bc0b67c1845a5e9e9546 /modules/templates/static.go | |
parent | 412583a3f28162c89e827fbb586319ac8eea9825 (diff) | |
download | gitea-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/static.go')
-rw-r--r-- | modules/templates/static.go | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/modules/templates/static.go b/modules/templates/static.go index 65b82053fd..c16b18cc08 100644 --- a/modules/templates/static.go +++ b/modules/templates/static.go @@ -43,8 +43,7 @@ func (templates templateFileSystem) Get(name string) (io.Reader, error) { return nil, fmt.Errorf("file '%s' not found", name) } -// Renderer implements the macaron handler for serving the templates. -func Renderer() macaron.Handler { +func NewTemplateFileSystem() templateFileSystem { fs := templateFileSystem{} fs.files = make([]macaron.TemplateFile, 0, 10) @@ -110,9 +109,25 @@ func Renderer() macaron.Handler { } } + return fs +} + +var tplFileSys = NewTemplateFileSystem() + +// HTMLRenderer implements the macaron handler for serving HTML templates. +func HTMLRenderer() macaron.Handler { + return macaron.Renderer(macaron.RenderOptions{ + Funcs: NewFuncMap(), + TemplateFileSystem: tplFileSys, + }) +} + +// JSONRenderer implements the macaron handler for serving JSON templates. +func JSONRenderer() macaron.Handler { return macaron.Renderer(macaron.RenderOptions{ Funcs: NewFuncMap(), - TemplateFileSystem: fs, + TemplateFileSystem: tplFileSys, + HTMLContentType: "application/json", }) } |