From c63022b6364014e6c3844d8a59efa58ce67dcc07 Mon Sep 17 00:00:00 2001 From: Stephen Searles Date: Sun, 6 Aug 2017 22:07:53 -0700 Subject: [PATCH] improvements; fixes --- deltas.go | 7 +++++-- http.go | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/deltas.go b/deltas.go index 5c62a31..afe47fd 100644 --- a/deltas.go +++ b/deltas.go @@ -86,7 +86,10 @@ func (ch *CaddyHugo) handleConn(conn DeltaConn, doc *docref) (int, error) { timer := time.NewTimer(idlePing) resetTimer := func(d time.Duration) { if !timer.Stop() { - <-timer.C + select { + case <-timer.C: + default: + } } timer.Reset(d) } @@ -145,7 +148,7 @@ func (ch *CaddyHugo) handleConn(conn DeltaConn, doc *docref) (int, error) { for { select { case err := <-errCh: - fmt.Println(err) + fmt.Println("error handling websocket connection:", err) return 500, err default: } diff --git a/http.go b/http.go index aec0178..0549833 100644 --- a/http.go +++ b/http.go @@ -43,6 +43,18 @@ func (ch *CaddyHugo) ServeHTTPWithNext(next httpserver.Handler, c *caddy.Control w.Write(assets.MustAsset("simplemde/debug/simplemde.js")) return http.StatusOK, nil } + if strings.HasPrefix(r.URL.Path, "/hugo/vue.js") { + w.Write(assets.MustAsset("js/vue.js")) + return http.StatusOK, nil + } + if strings.HasPrefix(r.URL.Path, "/hugo/moment.js") { + w.Write(assets.MustAsset("js/moment.js")) + return http.StatusOK, nil + } + if strings.HasPrefix(r.URL.Path, "/hugo/font-awesome.css") { + w.Write(assets.MustAsset("css/font-awesome.min.css")) + return http.StatusOK, nil + } if strings.HasPrefix(r.URL.Path, "/hugo/admin") { return ch.Admin().ServeHTTP(w, r) }