Route constructor

Route({
  1. required String path,
  2. required HttpMethod method,
  3. required RequestHandler handler,
  4. FilterConfig? filterConfig,
})

Implementation

factory Route({
  required String path,
  required HttpMethod method,
  required RequestHandler handler,
  FilterConfig? filterConfig,
}) {
  if (!path.startsWith('/')) {
    throw ArgumentError.value(
      path,
      'path',
      'expected route to start with a slash',
    );
  }

  return Route._(
    path,
    method,
    handler,
    filterConfig ?? const FilterConfig([]),
  );
}