parseRoute analyzes the route and divides it into segments for constant areas and parameters, this information is needed later when assigning the requests to the declared routes
(pattern string, regexHandler any, customConstraints ...CustomConstraint)
| 239 | // parseRoute analyzes the route and divides it into segments for constant areas and parameters, |
| 240 | // this information is needed later when assigning the requests to the declared routes |
| 241 | func (parser *routeParser) parseRoute(pattern string, regexHandler any, customConstraints ...CustomConstraint) { |
| 242 | var n int |
| 243 | var seg *routeSegment |
| 244 | for pattern != "" { |
| 245 | nextParamPosition := findNextParamPosition(pattern) |
| 246 | // handle the parameter part |
| 247 | if nextParamPosition == 0 { |
| 248 | n, seg = parser.analyseParameterPart(pattern, regexHandler, customConstraints...) |
| 249 | parser.params, parser.segs = append(parser.params, seg.ParamName), append(parser.segs, seg) |
| 250 | } else { |
| 251 | n, seg = parser.analyseConstantPart(pattern, nextParamPosition) |
| 252 | parser.segs = append(parser.segs, seg) |
| 253 | } |
| 254 | pattern = pattern[n:] |
| 255 | } |
| 256 | // mark last segment |
| 257 | if len(parser.segs) > 0 { |
| 258 | parser.segs[len(parser.segs)-1].IsLast = true |
| 259 | } |
| 260 | parser.segs = addParameterMetaInfo(parser.segs) |
| 261 | } |
| 262 | |
| 263 | // parseRoute analyzes the route and divides it into segments for constant areas and parameters, |
| 264 | // this information is needed later when assigning the requests to the declared routes |
no test coverage detected