buildFromController static method

Future<Router> buildFromController(
  1. Object controller
)

Builds a router from a controller using annotations when possible.

Implementation

static Future<Router> buildFromController(Object controller) async {
  // Try to use reflection first
  final reflectionRouter = await ReflectionHelper.buildRoutesWithReflection(controller);

  if (reflectionRouter != null) {
    Log.i('Routes built successfully using reflection');
    return reflectionRouter;
  }

  // Fallback: return empty router with instructions
  Log.w('Reflection not available. Please override the router getter manually.');
  Log.w('Example: @override Router get router { final r = Router(); r.get("/", handler); return r; }');

  return Router();
}