Added middleware to let excluded files skip middleware chain

This commit is contained in:
2025-02-11 19:37:39 +11:00
parent 750de24fd1
commit 97aabcf06f
6 changed files with 75 additions and 9 deletions

17
middleware/favicon.go Normal file
View File

@@ -0,0 +1,17 @@
package middleware
import (
"net/http"
)
func Favicon(next http.Handler) http.Handler {
return http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/favicon.ico" {
http.ServeFile(w, r, "static/favicon.ico")
} else {
next.ServeHTTP(w, r)
}
},
)
}