This commit is contained in:
2026-07-25 14:55:41 -05:00
parent cd61add56f
commit d5faf998f4
4 changed files with 61 additions and 10 deletions
+12 -8
View File
@@ -110,14 +110,7 @@ func New(cfg Config) (*Server, error) {
return nil, fmt.Errorf("database: %w", err)
}
templates, err := template.New("").Funcs(template.FuncMap{
"formatTime": func(value time.Time) string {
return value.Local().Format("Jan 2, 2006 3:04 PM")
},
"isActive": func(record authorizationRecord) bool {
return !record.RevokedAt.Valid && time.Now().Before(record.ExpiresAt)
},
}).ParseFS(webFiles, "templates/*.html")
templates, err := parseTemplates()
if err != nil {
_ = db.Close()
return nil, err
@@ -154,6 +147,17 @@ func New(cfg Config) (*Server, error) {
}, nil
}
func parseTemplates() (*template.Template, error) {
return template.New("").Funcs(template.FuncMap{
"formatTime": func(value time.Time) string {
return value.Local().Format("Jan 2, 2006 3:04 PM")
},
"isActive": func(record authorizationRecord) bool {
return !record.RevokedAt.Valid && time.Now().Before(record.ExpiresAt)
},
}).ParseFS(webFiles, "templates/*.html")
}
func (s *Server) Close() error {
return s.db.Close()
}