added glob matching for ignored paths in hws
This commit is contained in:
@@ -2,8 +2,9 @@ package hws
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/gobwas/glob"
|
||||
)
|
||||
|
||||
// Middleware to add logs to console with details of the request
|
||||
@@ -13,7 +14,7 @@ func logging(next http.Handler, logger *logger) http.Handler {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
if slices.Contains(logger.ignoredPaths, r.URL.Path) {
|
||||
if globTest(r.URL.Path, logger.ignoredPaths) {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
@@ -36,3 +37,12 @@ func logging(next http.Handler, logger *logger) http.Handler {
|
||||
Msg("Served")
|
||||
})
|
||||
}
|
||||
|
||||
func globTest(testPath string, globs []glob.Glob) bool {
|
||||
for _, g := range globs {
|
||||
if g.Match(testPath) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user