1
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
// MiddlewareNoiseSilence 静默浏览器/DevTools 噪音探测路径(favicon、well-known),避免访问日志刷 404
|
||||
func MiddlewareNoiseSilence(r *ghttp.Request) {
|
||||
p := r.URL.Path
|
||||
if p == "/favicon.ico" || strings.HasPrefix(p, "/.well-known/") {
|
||||
r.Response.WriteHeader(http.StatusNoContent)
|
||||
r.Exit()
|
||||
return
|
||||
}
|
||||
r.Middleware.Next()
|
||||
}
|
||||
Reference in New Issue
Block a user