| 178 | } |
| 179 | |
| 180 | func (r *Route) match(detectionPath, path string, params *[maxParams]string) bool { |
| 181 | // root detectionPath check |
| 182 | if r.root && len(detectionPath) == 1 && detectionPath[0] == '/' { |
| 183 | return true |
| 184 | } |
| 185 | |
| 186 | // '*' wildcard matches any detectionPath |
| 187 | if r.star { |
| 188 | if len(path) > 1 { |
| 189 | params[0] = path[1:] |
| 190 | } else { |
| 191 | params[0] = "" |
| 192 | } |
| 193 | return true |
| 194 | } |
| 195 | |
| 196 | // Does this route have parameters? |
| 197 | if len(r.Params) > 0 { |
| 198 | // Match params using precomputed routeParser |
| 199 | return r.routeParser.getMatch(detectionPath, path, params, r.use) |
| 200 | } |
| 201 | |
| 202 | // Middleware route? |
| 203 | if r.use { |
| 204 | // Single slash or prefix match |
| 205 | plen := len(r.path) |
| 206 | if r.root { |
| 207 | // If r.root is '/', it matches everything starting at '/' |
| 208 | if detectionPath != "" && detectionPath[0] == '/' { |
| 209 | return true |
| 210 | } |
| 211 | } else if len(detectionPath) >= plen && detectionPath[:plen] == r.path { |
| 212 | if hasPartialMatchBoundary(detectionPath, plen) { |
| 213 | return true |
| 214 | } |
| 215 | } |
| 216 | } else if len(r.path) == len(detectionPath) && detectionPath == r.path { |
| 217 | // Check exact match |
| 218 | return true |
| 219 | } |
| 220 | |
| 221 | // No match |
| 222 | return false |
| 223 | } |
| 224 | |
| 225 | func (app *App) next(c *DefaultCtx) (bool, error) { |
| 226 | methodInt := c.methodInt |