(routeMatcher RouteMatcher, r *http.Request)
| 50 | } |
| 51 | |
| 52 | func getRouteName(routeMatcher RouteMatcher, r *http.Request) string { |
| 53 | var routeMatch mux.RouteMatch |
| 54 | if routeMatcher == nil || !routeMatcher.Match(r, &routeMatch) { |
| 55 | return "" |
| 56 | } |
| 57 | |
| 58 | if routeMatch.MatchErr == mux.ErrNotFound { |
| 59 | return "notfound" |
| 60 | } |
| 61 | |
| 62 | if routeMatch.Route == nil { |
| 63 | return "" |
| 64 | } |
| 65 | |
| 66 | if name := routeMatch.Route.GetName(); name != "" { |
| 67 | return name |
| 68 | } |
| 69 | |
| 70 | tmpl, err := routeMatch.Route.GetPathTemplate() |
| 71 | if err == nil { |
| 72 | return MakeLabelValue(tmpl) |
| 73 | } |
| 74 | |
| 75 | return "" |
| 76 | } |
| 77 | |
| 78 | var invalidChars = regexp.MustCompile(`[^a-zA-Z0-9]+`) |
| 79 |
no test coverage detected