MCPcopy
hub / github.com/labstack/echo / captureTokens

Function captureTokens

middleware/middleware.go:21–34  ·  view source on GitHub ↗
(pattern *regexp.Regexp, input string)

Source from the content-addressed store, hash-verified

19type BeforeFunc func(c *echo.Context)
20
21func captureTokens(pattern *regexp.Regexp, input string) *strings.Replacer {
22 groups := pattern.FindAllStringSubmatch(input, -1)
23 if groups == nil {
24 return nil
25 }
26 values := groups[0][1:]
27 replace := make([]string, 2*len(values))
28 for i, v := range values {
29 j := 2 * i
30 replace[j] = "$" + strconv.Itoa(i+1)
31 replace[j+1] = v
32 }
33 return strings.NewReplacer(replace...)
34}
35
36func rewriteRulesRegex(rewrite map[string]string) map[*regexp.Regexp]string {
37 // Initialize

Callers 1

rewriteURLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…