Swagger.v1.json template (#3572)
* Turn swagger.v1.json into template * Rename ENABLE_SWAGGER_ENDPOINT option to ENABLE_SWAGGER
This commit is contained in:
parent
412583a3f2
commit
a74426d631
14 changed files with 74 additions and 21 deletions
|
@ -264,7 +264,7 @@ func Contexter() macaron.Handler {
|
|||
ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton
|
||||
ctx.Data["ShowFooterBranding"] = setting.ShowFooterBranding
|
||||
ctx.Data["ShowFooterVersion"] = setting.ShowFooterVersion
|
||||
ctx.Data["EnableSwaggerEndpoint"] = setting.API.EnableSwaggerEndpoint
|
||||
ctx.Data["EnableSwagger"] = setting.API.EnableSwagger
|
||||
ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
|
||||
|
||||
c.Map(ctx)
|
||||
|
|
|
@ -527,11 +527,11 @@ var (
|
|||
|
||||
// API settings
|
||||
API = struct {
|
||||
EnableSwaggerEndpoint bool
|
||||
MaxResponseItems int
|
||||
EnableSwagger bool
|
||||
MaxResponseItems int
|
||||
}{
|
||||
EnableSwaggerEndpoint: true,
|
||||
MaxResponseItems: 50,
|
||||
EnableSwagger: true,
|
||||
MaxResponseItems: 50,
|
||||
}
|
||||
|
||||
U2F = struct {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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",
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue