Adds SetHTMLTemplate() warning
This commit is contained in:
parent
4998bc2b2e
commit
00b279c66b
8
gin.go
8
gin.go
@ -116,6 +116,14 @@ func (engine *Engine) LoadHTMLFiles(files ...string) {
|
||||
}
|
||||
|
||||
func (engine *Engine) SetHTMLTemplate(templ *template.Template) {
|
||||
if len(engine.trees) > 0 {
|
||||
debugPrint(`[WARNING] Since SetHTMLTemplate() is NOT thread-safe. It should only be called
|
||||
at initialization. ie. before any route is registered or the router is listening in a socket:
|
||||
|
||||
router := gin.Default()
|
||||
router.SetHTMLTemplate(template) // << good place
|
||||
`)
|
||||
}
|
||||
engine.HTMLRender = render.HTMLProduction{Template: templ}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user