handle method

RouteBuilder handle(
  1. String method,
  2. String path,
  3. RouteHandler handler, {
  4. List<Middleware> middlewares = const [],
  5. Map<String, dynamic> constraints = const {},
  6. Object? schema,
})

Internal helper to create and store a RegisteredRoute.

method: The HTTP method for the route (e.g., GET, POST). path: The path for the route. handler: The handler function for the route. middlewares: Optional middlewares specific to this route. constraints: Optional constraints for the route parameters. schema: Optional API schema metadata for this route.

Implementation

RouteBuilder handle(
  String method,
  String path,
  RouteHandler handler, {
  List<Middleware> middlewares = const [],
  Map<String, dynamic> constraints = const {},
  Object? schema,
}) {
  final source = _captureRouteRegistrationSource();
  final fullPath = _joinPaths(_prefix, path);
  final route = RegisteredRoute(
    method: method,
    path: fullPath,
    handler: handler,
    routeMiddlewares: middlewares,
    constraints: constraints,
    sourceFile: source.file,
    sourceLine: source.line,
    sourceColumn: source.column,
    schema: schema,
  );
  _routes.add(route);
  return RouteBuilder(route, this);
}