...
1 package restful
2
3 import (
4 "fmt"
5 "regexp"
6 )
7
8 var (
9 customVerbReg = regexp.MustCompile(":([A-Za-z]+)$")
10 )
11
12 func hasCustomVerb(routeToken string) bool {
13 return customVerbReg.MatchString(routeToken)
14 }
15
16 func isMatchCustomVerb(routeToken string, pathToken string) bool {
17 rs := customVerbReg.FindStringSubmatch(routeToken)
18 if len(rs) < 2 {
19 return false
20 }
21
22 customVerb := rs[1]
23 specificVerbReg := regexp.MustCompile(fmt.Sprintf(":%s$", customVerb))
24 return specificVerbReg.MatchString(pathToken)
25 }
26
27 func removeCustomVerb(str string) string {
28 return customVerbReg.ReplaceAllString(str, "")
29 }
30
View as plain text