summaryrefslogtreecommitdiffstats
path: root/app/app.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-11-20 11:57:45 -0600
committerHarrison Healey <harrisonmhealey@gmail.com>2017-11-20 12:57:45 -0500
commit5cf45d21559eb4f8c69f57e9d50bcd4d00b9d430 (patch)
tree87e4513f933e956390dced4c14c766adeac1081f /app/app.go
parent7eb75093937076df0d7f95ab85b6d10b40383521 (diff)
downloadchat-5cf45d21559eb4f8c69f57e9d50bcd4d00b9d430.tar.gz
chat-5cf45d21559eb4f8c69f57e9d50bcd4d00b9d430.tar.bz2
chat-5cf45d21559eb4f8c69f57e9d50bcd4d00b9d430.zip
refactor template code (#7860)
Diffstat (limited to 'app/app.go')
-rw-r--r--app/app.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/app/app.go b/app/app.go
index 49ac620e8..55fb43b30 100644
--- a/app/app.go
+++ b/app/app.go
@@ -4,6 +4,7 @@
package app
import (
+ "html/template"
"net/http"
"runtime/debug"
"sync/atomic"
@@ -52,7 +53,8 @@ type App struct {
configFile string
newStore func() store.Store
- sessionCache *utils.Cache
+ htmlTemplateWatcher *utils.HTMLTemplateWatcher
+ sessionCache *utils.Cache
}
var appCount = 0
@@ -94,6 +96,12 @@ func New(options ...Option) *App {
}
}
+ if htmlTemplateWatcher, err := utils.NewHTMLTemplateWatcher("templates"); err != nil {
+ l4g.Error(utils.T("api.api.init.parsing_templates.error"), err)
+ } else {
+ app.htmlTemplateWatcher = htmlTemplateWatcher
+ }
+
app.Srv.Store = app.newStore()
app.initJobs()
@@ -125,6 +133,10 @@ func (a *App) Shutdown() {
a.Srv.Store.Close()
a.Srv = nil
+ if a.htmlTemplateWatcher != nil {
+ a.htmlTemplateWatcher.Close()
+ }
+
l4g.Info(utils.T("api.server.stop_server.stopped.info"))
}
@@ -327,6 +339,10 @@ func (a *App) WaitForGoroutines() {
}
}
+func (a *App) HTMLTemplates() *template.Template {
+ return a.htmlTemplateWatcher.Templates()
+}
+
func (a *App) Handle404(w http.ResponseWriter, r *http.Request) {
err := model.NewAppError("Handle404", "api.context.404.app_error", nil, "", http.StatusNotFound)
err.Translate(utils.T)