-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: logging and cache middleware (#72)
* Fix logging and cache middleware * linter * minor fix * linter * fixes * Enhanced cache config * linter * minor change * update comment
- Loading branch information
1 parent
070ffcb
commit 58a3190
Showing
5 changed files
with
86 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package zmiddlewares | ||
|
||
import ( | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
func PathToRegexp(path string) *regexp.Regexp { | ||
escapedPath := regexp.QuoteMeta(path) | ||
escapedPath = strings.ReplaceAll(escapedPath, "\\{", "{") | ||
escapedPath = strings.ReplaceAll(escapedPath, "\\}", "}") | ||
|
||
pattern := regexp.MustCompile(`\{[^}]*\}`).ReplaceAllString(escapedPath, "[^/]+") | ||
return regexp.MustCompile("^" + pattern + "$") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters