Skip to content

Commit

Permalink
shovel/web: bugfix. localhost dashboard access
Browse files Browse the repository at this point in the history
This code incorrectly assumed that if you were accessing the dashboard
over localhost then you were running shovel in dev and would have access
to the html templates on the fs. This is incorrect. You may want to
access the dashboard over localhost using the released binaries, in
which case you don't have the html on the fs. So now we always fall back
to the html in the compiled binary. We also log in case something is
going wrong in dev.
  • Loading branch information
ryandotsmith committed Apr 7, 2024
1 parent 83d9791 commit e1f2323
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions shovel/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ func (h *Handler) PushUpdates() error {
func (h *Handler) template(local bool, name string) (*template.Template, error) {
if local {
b, err := os.ReadFile(fmt.Sprintf("./shovel/web/%s.html", name))
if err != nil {
return nil, fmt.Errorf("reading %s: %w", name, err)
if err == nil {
return template.New(name).Parse(string(b))
}
return template.New(name).Parse(string(b))
slog.Info("using pre-compiled html templates")
}
t, ok := h.templates[name]
if ok {
Expand Down

0 comments on commit e1f2323

Please sign in to comment.