Added middleware to let excluded files skip middleware chain
This commit is contained in:
17
middleware/favicon.go
Normal file
17
middleware/favicon.go
Normal 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)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user