Compare commits
No commits in common. "377fcd0230b1cde51caaaf02503dead87d54d6fa" and "bba66fe4cc0df179d7a3733c403c0276f291ae30" have entirely different histories.
377fcd0230
...
bba66fe4cc
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module git.twelvetwelve.org/library/snap
|
|||
go 1.20
|
||||
|
||||
require (
|
||||
git.twelvetwelve.org/library/core v0.2.0
|
||||
git.twelvetwelve.org/library/core v0.1.1-0.20240416170915-b309a62d2748
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
)
|
||||
|
|
6
go.sum
6
go.sum
|
@ -1,5 +1,7 @@
|
|||
git.twelvetwelve.org/library/core v0.2.0 h1:ieCtwuwAhla/h/NZwm0NZwIPkC285dsas64/6nlPRY0=
|
||||
git.twelvetwelve.org/library/core v0.2.0/go.mod h1:D95+y6AdDBvviXryconVQdgDzxCaLCjq6gi3YknBgp0=
|
||||
git.twelvetwelve.org/library/core v0.0.0-20230519041221-8f2da7be661d h1:vZy7QM4kcGzbscnY1pSOGNDBDZMmhis/Z+9kZ70gD8Q=
|
||||
git.twelvetwelve.org/library/core v0.0.0-20230519041221-8f2da7be661d/go.mod h1:QSIAU+Arcx8nd7p4e3hFQIqi50cYf9I0KW9sqxkFnMY=
|
||||
git.twelvetwelve.org/library/core v0.1.1-0.20240416170915-b309a62d2748 h1:/rkWOGgiJxOf9mo9/x7Vw2aCHwCUIoaIa2xWxZo4o18=
|
||||
git.twelvetwelve.org/library/core v0.1.1-0.20240416170915-b309a62d2748/go.mod h1:D95+y6AdDBvviXryconVQdgDzxCaLCjq6gi3YknBgp0=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
|
|
16
server.go
16
server.go
|
@ -23,7 +23,6 @@ import (
|
|||
)
|
||||
|
||||
type Server struct {
|
||||
log log.Logger
|
||||
address string
|
||||
theme string
|
||||
debug bool
|
||||
|
@ -212,7 +211,7 @@ func (s *Server) LoadTemplatesFS(fs http.FileSystem, base string) (*template.Tem
|
|||
if strings.Contains(path, ".html") {
|
||||
_, err := s.parseTemplates(tmpl, path)
|
||||
if err != nil {
|
||||
s.log.Printf("%+v\n", err)
|
||||
log.Printf("%+v\n", err)
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
@ -228,7 +227,7 @@ func (s *Server) LoadTemplatesFS(fs http.FileSystem, base string) (*template.Tem
|
|||
func (s *Server) loadTemplates() *template.Template {
|
||||
tmpl, err := s.LoadTemplatesFS(s.fs, s.templates)
|
||||
if err != nil {
|
||||
s.log.Fatalf("loadTemplates %v %v\n", err, s.templates)
|
||||
log.Fatalf("loadTemplates %v %v\n", err, s.templates)
|
||||
}
|
||||
return tmpl
|
||||
}
|
||||
|
@ -255,7 +254,7 @@ func (s *Server) render(w http.ResponseWriter, tmpl string, content interface{})
|
|||
}
|
||||
err := s.getTemplates().ExecuteTemplate(w, tmpl, content)
|
||||
if err != nil {
|
||||
s.log.Warnf("%s\n", err)
|
||||
log.Warnf("%s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,7 +284,7 @@ func (s *Server) HandleFuncAuthenticatedWithLogin(path string, loginHandler func
|
|||
|
||||
func (s *Server) HandleFuncCustomAuth(auth auth.Authenticator, path, redirect string, f func(c *Context)) *mux.Route {
|
||||
if auth == nil {
|
||||
s.log.Warnf("Nil auth on %s\n", path)
|
||||
log.Warnf("Nil auth on %s\n", path)
|
||||
return nil
|
||||
}
|
||||
return s.router.HandleFunc(path, s.authenticated(auth, redirect, f))
|
||||
|
@ -321,7 +320,7 @@ func (s *Server) Router() *mux.Router {
|
|||
func (s *Server) ServeTLS(keyPath string, certPath string) error {
|
||||
kpr, err := autocert.NewManager(certPath, keyPath)
|
||||
if err != nil {
|
||||
s.log.Fatalf("%v\n", err)
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
|
||||
s.http = &http.Server{
|
||||
|
@ -423,10 +422,6 @@ func (s *Server) WithHealthCheck(version, date string, status func() (bool, stri
|
|||
})
|
||||
}
|
||||
|
||||
func (s *Server) SetLogger(logger log.Logger) {
|
||||
s.log = logger
|
||||
}
|
||||
|
||||
func (s *Server) Dump() {
|
||||
fmt.Printf(" Theme: %s\n", s.theme)
|
||||
fmt.Printf(" Templates: %s\n", s.templates)
|
||||
|
@ -448,7 +443,6 @@ func New(address string, path string, auth auth.Authenticator) *Server {
|
|||
templateFuncs: builtinFuncMap,
|
||||
theme: "/static/css/default.css",
|
||||
meta: make(map[string]string),
|
||||
log: log.WithName("SNAP"),
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue