mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Swagger.v1.json template (#3572)
* Turn swagger.v1.json into template * Rename ENABLE_SWAGGER_ENDPOINT option to ENABLE_SWAGGER
This commit is contained in:
committed by
Lauris BH
parent
412583a3f2
commit
a74426d631
@@ -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: fs,
|
||||
TemplateFileSystem: tplFileSys,
|
||||
})
|
||||
}
|
||||
|
||||
// JSONRenderer implements the macaron handler for serving JSON templates.
|
||||
func JSONRenderer() macaron.Handler {
|
||||
return macaron.Renderer(macaron.RenderOptions{
|
||||
Funcs: NewFuncMap(),
|
||||
TemplateFileSystem: tplFileSys,
|
||||
HTMLContentType: "application/json",
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user