From e33e5662c7cdffd3eed5e01923280c2660b40a0a Mon Sep 17 00:00:00 2001 From: Ajit D'Sa Date: Tue, 30 Sep 2025 13:46:59 -0500 Subject: [PATCH] fix(liteboard): comply with Rack 3 Lint in development; add 404 and favicon handlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Return lowercase response headers and explicit content-type from Liteboard#after to satisfy Rack 3 Lint (Cache-Control → cache-control). - Add explicit /favicon.ico handler returning 204 No Content to avoid repeated browser requests and ensure a valid Rack triplet. - Add default 404 handler for unmatched routes so every request path returns a proper [status, headers, body] response. This resolves errors seen in development with Rack 3: - Rack::Lint::LintError: uppercase character in header name: Cache-Control - NoMethodError in Rack::TempfileReaper when an unmatched path returned nil. Repro: liteboard -d db/development.sqlite3 --env=development Visit "/" and "/favicon.ico" Issue: Loading liteboard in development gave the following error: `Rack::Lint::LintError: uppercase character in header name: Cache-Control (Rack::Lint::LintError)` Also, there was no handler for favicon.ico, so I added one. After: Both routes return valid responses; no Rack::Lint or TempfileReaper errors. --- lib/litestack/liteboard/liteboard.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/litestack/liteboard/liteboard.rb b/lib/litestack/liteboard/liteboard.rb index b8c2551..30d43d2 100644 --- a/lib/litestack/liteboard/liteboard.rb +++ b/lib/litestack/liteboard/liteboard.rb @@ -15,6 +15,8 @@ class Liteboard case env["PATH_INFO"] when "/" Liteboard.new(env).call(:index) + when "/favicon.ico" + [204, {"cache-control" => "no-cache"}, []] when "/topics/Litejob" Liteboard.new(env).call(:litejob) when "/topics/Litecache" @@ -23,6 +25,8 @@ class Liteboard Liteboard.new(env).call(:litedb) when "/topics/Litecable" Liteboard.new(env).call(:litecable) + else + [404, {"content-type" => "text/plain; charset=utf-8", "cache-control" => "no-cache"}, ["Not Found"]] end end @@ -45,7 +49,7 @@ def call(method) end def after(body = nil) - [200, {"Cache-Control" => "no-cache"}, [body]] + [200, {"cache-control" => "no-cache", "content-type" => "text/html; charset=utf-8"}, [body]] end def before