From bfd936ab717c6d4e4e50bbd0f797c3d1fc7eda42 Mon Sep 17 00:00:00 2001
From: xengineering <me@xengineering.eu>
Date: Thu, 15 Feb 2024 20:18:19 +0100
Subject: view: Add HTTP 204 handler for /favicon.ico

Otherwise e.g. the Firefox browser throws an error on the console.
---
 main.go         | 1 +
 view/favicon.go | 9 +++++++++
 2 files changed, 10 insertions(+)
 create mode 100644 view/favicon.go

diff --git a/main.go b/main.go
index 2f398b3..ec811c9 100644
--- a/main.go
+++ b/main.go
@@ -45,6 +45,7 @@ func startServer(addr string) *http.Server {
 		Handler(http.StripPrefix("/static/", http.FileServer(http.FS(static))))
 	r.HandleFunc("/recipes", view.Recipes).Methods(`GET`)
 	r.HandleFunc("/recipe/{id:[0-9]+}", view.Recipe).Methods(`GET`)
+	r.HandleFunc("/favicon.ico", view.Favicon).Methods(`GET`)
 	r.HandleFunc("/", view.Index).Methods(`GET`)
 
 	muxer := http.NewServeMux()
diff --git a/view/favicon.go b/view/favicon.go
new file mode 100644
index 0000000..65bfaef
--- /dev/null
+++ b/view/favicon.go
@@ -0,0 +1,9 @@
+package view
+
+import (
+	"net/http"
+)
+
+func Favicon(w http.ResponseWriter, r *http.Request) {
+	w.WriteHeader(http.StatusNoContent)
+}
-- 
cgit v1.2.3-70-g09d2