fix livereload handler error
1 file changed, 9 insertions(+), 2 deletions(-)
changed files
M internal/server/server.go → internal/server/server.go
@@ -6,6 +6,7 @@ "fmt" "net/http" "time" + "github.com/osdevisnot/sorvor/pkg/livereload" "go.alanpearce.eu/x/log" "gitlab.com/tozd/go/errors"@@ -26,8 +27,9 @@ type Options struct { ListenAddress string `conf:"default:localhost"` Port int `conf:"default:8080,short:p"` - Domains []string `conf:"-"` - WildcardDomains []string `conf:"-"` + LiveReload *livereload.LiveReload `conf:"-"` + Domains []string `conf:"-"` + WildcardDomains []string `conf:"-"` } type Server struct {@@ -81,6 +83,11 @@ serverHeaderHandler( wrapHandlerWithLogging(s.mux, s.log), ), ) + + if s.options.LiveReload != nil { + top.Handle("/_/reload", s.options.LiveReload) + s.options.LiveReload.Start() + } top.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNoContent)