toMap method

List<Map> toMap(
  1. String parentPath,
  2. bool hasAuth,
  3. String method
)

Converts the route to a list of maps representing its details.

parentPath is the base path for the route. hasAuth indicates whether the route requires authentication. method is the HTTP method being used.

Returns a list of maps containing details about the route.

Implementation

List<Map> toMap(String parentPath, bool hasAuth, String method) {
  var res = <Map>[];
  final endpoint = endpointNorm([parentPath, path]);
  res.add({
    'path': path,
    'fullPath': endpoint,
    'hasAuth': hasAuth || auth != null,
    'method': method,
    'value': "[$method]$endpoint",
    'type': endpoint.startsWith('/api/') ? 'API' : 'WEB',
    'permissions': permissions,
    'controller': controller?.toString(short: true),
    'index':
        index?.toString().split(' ').last.replaceAll(RegExp(r"[:'.]"), ''),
    'hosts': hosts,
    'ports': ports,
  });

  for (var epath in extraPath) {
    var eEndpoint = endpointNorm([parentPath, epath]);
    res.add({
      'path': epath,
      'fullPath': eEndpoint,
      'hasAuth': hasAuth || auth != null,
      'method': method,
      'value': "[$method]$eEndpoint",
      'type': eEndpoint.startsWith('/api/') ? 'API' : 'WEB',
      'permissions': permissions,
      'controller': controller?.toString(short: true),
      'index':
          index?.toString().split(' ').last.replaceAll(RegExp(r"[:'.]"), ''),
      'hosts': hosts,
      'ports': ports,
    });
  }

  return res;
}