From fde36e45b10825aea767a76203caa0054309b1d6 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Thu, 3 Jul 2025 13:56:48 +0700 Subject: [PATCH] feat: update client middleware --- app/middleware/client.middleware.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/middleware/client.middleware.go b/app/middleware/client.middleware.go index e5b4181..5d26cf9 100644 --- a/app/middleware/client.middleware.go +++ b/app/middleware/client.middleware.go @@ -21,14 +21,19 @@ var excludedPaths = []string{ "/health/*", "/clients", "/clients/*", - "/metrics", - "/metrics/*", + "*/viewer/*", } // isPathExcluded checks if the given path should be excluded from client key validation func isPathExcluded(path string) bool { for _, excludedPath := range excludedPaths { - if strings.HasPrefix(excludedPath, "*") { + if strings.HasPrefix(excludedPath, "*") && strings.HasSuffix(excludedPath, "*") { + // Handle wildcard at both beginning and end (e.g., "*/viewer/*") + pattern := excludedPath[1 : len(excludedPath)-1] // Remove * from both ends + if strings.Contains(path, pattern) { + return true + } + } else if strings.HasPrefix(excludedPath, "*") { // Handle wildcard at the beginning if strings.HasSuffix(path, excludedPath[1:]) { return true