update
This commit is contained in:
+12
-8
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user