From ce4bf2f646964cc103d541f1ce610aec9035775f Mon Sep 17 00:00:00 2001 From: yusing Date: Mon, 28 Apr 2025 23:54:13 +0800 Subject: [PATCH] fix(idlewatcher): not started for docker containers --- internal/idlewatcher/handle_http.go | 4 ++++ internal/route/route.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/internal/idlewatcher/handle_http.go b/internal/idlewatcher/handle_http.go index 6d87f49..a0f65ee 100644 --- a/internal/idlewatcher/handle_http.go +++ b/internal/idlewatcher/handle_http.go @@ -38,6 +38,10 @@ func (w *Watcher) ServeHTTP(rw http.ResponseWriter, r *http.Request) { return default: f := &ForceCacheControl{expires: w.expires().Format(http.TimeFormat), ResponseWriter: rw} + w, ok := watcherMap[w.Key()] // could've been reloaded + if !ok { + return + } w.rp.ServeHTTP(f, r) } } diff --git a/internal/route/route.go b/internal/route/route.go index 4834d21..7adfcbd 100644 --- a/internal/route/route.go +++ b/internal/route/route.go @@ -151,6 +151,10 @@ func (r *Route) Validate() gperr.Error { } } + if r.Container != nil && r.Container.IdlewatcherConfig != nil { + r.Idlewatcher = r.Container.IdlewatcherConfig + } + // return error if route is localhost: switch r.Host { case "localhost", "127.0.0.1":