redstone-dart / redstone

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

Scan group hierarchy #177

Closed sestegra closed 8 years ago

sestegra commented 8 years ago

By adding a scan of a group hierarchy, we could override group behavior.

abstract class ServicesGroup {
  String name;
  ServicesGroup(this.name);

  @Route("/json", methods: const [POST])
  Map echoJson(@Body(JSON) Map json) {
    json["_name"] = name;
    return json;
  }

  @Route("/form", methods: const [POST])
  Map echoFormAsJson(@Body(FORM) Map form) {
    form["_name"] = name;
    return form;
  }
}

@Group("/one")
class OneServicesGroup extends ServicesGroup {
  OneServicesGroup(): super("one");
}

@Group("/two")
class TwoServicesGroup extends ServicesGroup {
  TwoServicesGroup(): super("two");
}
Configured target for /two/json [POST]: http_test.ServicesGroup.echoJson (group: http_test.TwoServicesGroup)
Configured target for /two/form [POST]: http_test.ServicesGroup.echoFormAsJson (group: http_test.TwoServicesGroup)
Configured target for /one/json [POST]: http_test.ServicesGroup.echoJson (group: http_test.OneServicesGroup)
Configured target for /one/form [POST]: http_test.ServicesGroup.echoFormAsJson (group: http_test.OneServicesGroup)
Pacane commented 8 years ago

Ping me when this gets updated, and I'll merge it

sestegra commented 8 years ago

Requested update done

Pacane commented 8 years ago

All good, thanks!