Address stale css on restart automatically

This commit is contained in:
spsobole 2024-06-10 09:23:28 -06:00
parent 377fcd0230
commit 96d0f7ea4b
2 changed files with 10 additions and 0 deletions

View File

@ -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 {

View File

@ -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
}