Route.fromInfo constructor

Route.fromInfo(
  1. HttpMethod info,
  2. RouteHandler handler, {
  3. List<RouteInterceptor>? after,
  4. List<RouteInterceptor>? before,
  5. List<ExceptionHandler>? onException,
})

Implementation

Route.fromInfo(this.info, this.handler,
    {List<RouteInterceptor>? after,
    List<RouteInterceptor>? before,
    List<ExceptionHandler>? onException})
    : pathSegments = pathToSegments(info.path),
      _before = before ?? [],
      _after = after ?? [],
      _onException = onException ?? [] {
  for (int i = 0; i < pathSegments.length; i++) {
    String seg = pathSegments.elementAt(i);
    if (seg.startsWith(':')) {
      if (i == pathSegments.length - 1 && seg.endsWith('*')) {
        _pathGlobVarMapping = i;
        _pathGlobVarName = seg.substring(1, seg.length - 1);
      } else {
        seg = seg.substring(1);
        if (seg.isNotEmpty) _pathVarMapping[seg] = i;
      }
    }
  }
}