redstone-dart / redstone

A metadata driven microframework for Dart.
http://redstone-dart.github.io/redstone
MIT License
342 stars 42 forks source link

Route handlers not scanned when not located in main.dart #73

Closed Pacane closed 9 years ago

Pacane commented 9 years ago

I'm trying to do this:

// in games.dart
class Games {
  @app.Route("/")
  helloWorld() => "Hello, World!";
}

// in main.dart

main () {
  app.setupConsoleLog();
  app.start(port:3010);
}

and the server starts fine, but doesn't register the GET handler on /. I tried adding this

  app.addModule(new Module()..bind(Games));

just before the call to start() but it won't help.

Do I really have to keep the annotations in main.dart ?

luizmineo commented 9 years ago

No, you don't. But you need to annotate your classes with @Group

Example:

@app.Group("/")
class Games {
  @app.Route("/")
  helloWorld() => "Hello, World!";
}

Or:

@app.Group("/")
class Games {
  @app.DefaultRoute()
  helloWorld() => "Hello, World!";
}
Pacane commented 9 years ago

Thanks, got it working! Also, nice job on this framework, it looks very good, and the documentation is pretty nice. Keep up the good work.