Refactor favicon middleware, avoid magic numbers. (#1919)

* Refactor favicon middleware, avoid magic numbers.

* Introduce constant for path to favicon.
pull/1924/head
Viktor Persson 2022-05-28 21:35:49 +02:00 committed by GitHub
parent 061c2a9e12
commit 68e922d733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -40,6 +40,7 @@ var ConfigDefault = Config{
}
const (
fPath = "/favicon.ico"
hType = "image/x-icon"
hAllow = "GET, HEAD, OPTIONS"
hZero = "0"
@ -97,7 +98,7 @@ func New(config ...Config) fiber.Handler {
}
// Only respond to favicon requests
if len(c.Path()) != 12 || c.Path() != "/favicon.ico" {
if c.Path() != fPath {
return c.Next()
}