diff --git a/context.go b/context.go index 37441bb..685c012 100644 --- a/context.go +++ b/context.go @@ -26,6 +26,7 @@ type SnapContent struct { Theme string Meta map[string]string Content interface{} + Version int64 } func (c *Context) GetRequest() *http.Request { @@ -106,6 +107,7 @@ func (c *Context) RenderEx(tmpl string, content interface{}) { Theme: c.srv.theme, Meta: c.srv.meta, Content: content, + Version: c.srv.version, } if c.auth != nil { @@ -132,6 +134,7 @@ func (c *Context) RenderWithMeta(tmpl string, meta map[string]string, content in Theme: c.srv.theme, Meta: meta, Content: content, + Version: c.srv.version, } if c.auth != nil { diff --git a/server.go b/server.go index 8469707..870922d 100644 --- a/server.go +++ b/server.go @@ -40,6 +40,7 @@ type Server struct { // testModeEnabled if test mode is enabled we will not render the template but jsut return the // json object testModeEnabled bool + version int64 } type SnapBaseContent struct { @@ -401,6 +402,11 @@ func (s *Server) WithAuth(auth auth.Authenticator) *Server { return s } +func (s *Server) WithVersion(version int64) *Server { + s.version = version + return s +} + func (s *Server) WithHealthCheck(version, date string, status func() (bool, string)) { s.HandleFunc("/_health", func(c *Context) { ok, msg := status() @@ -449,6 +455,7 @@ func New(address string, path string, auth auth.Authenticator) *Server { theme: "/static/css/default.css", meta: make(map[string]string), log: log.WithName("SNAP"), + version: time.Now().Unix(), } return &s }