Commit 55622c8ce99e85536810c9e3b405aa7347368c94

Parents: 1274083fbcb3bc114efa5d4cff328ca80f6a0197

From: Moritz Poldrack <git@moritz.sh>
Date: Mon Nov 20 13:33:19 2023 +0700

handler: don't 404 for favicon.ico

		

Stats

internal/handler/serve-http.go +10/-4

Changeset

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git a/internal/handler/serve-http.go b/internal/handler/serve-http.go
index 0a86257b90f95436abc20a7a05db14a5feb3fe73..ffee6578ffe1787b0d2c8d250e0cf88eca9667d6 100644
--- a/internal/handler/serve-http.go
+++ b/internal/handler/serve-http.go
@@ -1,6 +1,7 @@
 package handler
 
 import (
+	"bytes"
 	"log/slog"
 	"path/filepath"
 	"strings"
@@ -39,12 +40,17 @@ 			return
 		}
 	}
 
-	repo := h.lookupProject(string(ctx.Path()))
-	if repo == nil {
-		errorHandler(ctx, ErrNotFound)
+	if repo := h.lookupProject(string(ctx.Path())); repo != nil {
+		h.repoHandler(ctx, repo)
+		return
+	}
+
+	if bytes.Equal(ctx.Path(), []byte("/favicon.ico")) {
+		ctx.SetStatusCode(fasthttp.StatusNoContent)
 		return
 	}
-	h.repoHandler(ctx, repo)
+
+	errorHandler(ctx, ErrNotFound)
 }
 
 func (h *Handler) GoModulePath(host, path string) *types.Repo {