getControllerMethods static method
- Type controllerType
Obtiene la lista de métodos HTTP de un controlador
Implementation
static List<String> getControllerMethods(Type controllerType) {
if (!isReflectionAvailable) return [];
try {
final classMirror = mirrors.reflectClass(controllerType);
final methods = <String>[];
// Obtener todos los métodos que tienen anotaciones HTTP
for (final declaration in classMirror.declarations.entries) {
if (declaration.value is mirrors.MethodMirror) {
final methodMirror = declaration.value as mirrors.MethodMirror;
final methodName = declaration.key.toString();
// Verificar si el método tiene alguna anotación HTTP
for (final metadata in methodMirror.metadata) {
final annotation = metadata.reflectee;
if (_isHttpAnnotation(annotation)) {
methods.add(methodName);
break;
}
}
}
}
Log.d('Found ${methods.length} HTTP methods in $controllerType: ${methods.join(', ')}');
return methods;
} catch (e) {
Log.w('Failed to get controller methods for $controllerType: $e');
return [];
}
}