diff --git a/frontend/main.go b/frontend/main.go index 393e85a..3793166 100644 --- a/frontend/main.go +++ b/frontend/main.go @@ -91,12 +91,31 @@ func main() { mux.Handle("POST /account/tags/{id}/photo", app.RequireAuth(app.UploadPhoto)) mux.HandleFunc("GET /photos/{key...}", app.ServePhoto) + // Request logging: every hit (method, path, status, duration) goes to stdout + // so we can see exactly what phones send (diagnostics for the scan flow). + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + rec := &statusRecorder{ResponseWriter: w, status: 200} + mux.ServeHTTP(rec, r) + log.Printf("%s %s -> %d (%s)", r.Method, r.URL.RequestURI(), rec.status, time.Since(start).Round(time.Millisecond)) + }) + srv := &http.Server{ Addr: addr, - Handler: mux, + Handler: handler, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, } log.Println("wherewoof listening on", addr) log.Fatal(srv.ListenAndServe()) } + +type statusRecorder struct { + http.ResponseWriter + status int +} + +func (r *statusRecorder) WriteHeader(code int) { + r.status = code + r.ResponseWriter.WriteHeader(code) +} diff --git a/frontend/templates/tag-public.html b/frontend/templates/tag-public.html index 4cd592e..e24462c 100644 --- a/frontend/templates/tag-public.html +++ b/frontend/templates/tag-public.html @@ -145,6 +145,9 @@ {timeout: 20000, maximumAge: 0} ); } + // Fire a scan immediately so a tag view always reports (and alerts) — + // location is an upgrade, never a gate. + sendScan(null, null); if (btn) btn.addEventListener("click", tryLocation); tryLocation(); })();