Skip to content

Commit

Permalink
Refactor favicon middleware, avoid magic numbers. (#1919)
Browse files Browse the repository at this point in the history
* Refactor favicon middleware, avoid magic numbers.

* Introduce constant for path to favicon.
  • Loading branch information
vikpe committed May 28, 2022
1 parent 061c2a9 commit 68e922d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion middleware/favicon/favicon.go
Expand Up @@ -40,6 +40,7 @@ var ConfigDefault = Config{
}

const (
fPath = "/favicon.ico"
hType = "image/x-icon"
hAllow = "GET, HEAD, OPTIONS"
hZero = "0"
Expand Down Expand Up @@ -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()
}

Expand Down

1 comment on commit 68e922d

@ReneWerner87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 68e922d Previous: 061c2a9 Ratio
Benchmark_AcquireCtx 1289 ns/op 1440 B/op 5 allocs/op 491.1 ns/op 1440 B/op 5 allocs/op 2.62

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.