diff --git a/server.go b/server.go
index f0ba286..79507bc 100644
--- a/server.go
+++ b/server.go
@@ -46,6 +46,7 @@ type Server struct {
streams map[*http.Request]*streamInfo
lock sync.Mutex
version string
+ headContent template.HTML
}
type streamInfo struct {
@@ -113,6 +114,7 @@ func NewServer(config *Config, provider *Provider, version string) (*Server, err
totalStreams: 0,
streams: make(map[*http.Request]*streamInfo),
version: version,
+ headContent: headContent(version),
}
server.router.Use(gin.LoggerWithFormatter(logrusLogFormatter))
@@ -362,7 +364,7 @@ func (s *Server) debug() gin.HandlerFunc {
}
}
-func (s *Server) headContent() template.HTML {
+func headContent(version string) template.HTML {
if IsDebugMode() {
return template.HTML(`
@@ -396,19 +398,19 @@ func (s *Server) headContent() template.HTML {
`)
} else {
return template.HTML(fmt.Sprintf(`
- `, s.version))
+ `, version))
}
}
func (s *Server) homePage() gin.HandlerFunc {
- streamInfoData := s.getStreamInfoData()
- streamInfoData["HeadContent"] = s.headContent()
- if IsDebugMode() {
- streamInfoData["Version"] = "debug"
- } else {
- streamInfoData["Version"] = s.version
- }
return func(c *gin.Context) {
+ streamInfoData := s.getStreamInfoData()
+ streamInfoData["HeadContent"] = s.headContent
+ if IsDebugMode() {
+ streamInfoData["Version"] = "debug"
+ } else {
+ streamInfoData["Version"] = s.version
+ }
c.HTML(http.StatusOK, "base.html", streamInfoData)
}
}