MCPcopy
hub / github.com/gofiber/fiber / parseRoute

Method parseRoute

path.go:241–261  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
241func (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

Callers 2

parseRouteFunction · 0.95
RoutePatternMatchFunction · 0.80

Calls 4

analyseParameterPartMethod · 0.95
analyseConstantPartMethod · 0.95
findNextParamPositionFunction · 0.85
addParameterMetaInfoFunction · 0.85

Tested by

no test coverage detected