vibe-d / vibe.d

Official vibe.d development
MIT License
1.15k stars 284 forks source link

Create instances in registerWebInterface #436

Closed etcimon closed 8 years ago

etcimon commented 10 years ago

In theory it would be possible to have a recursive loop inside registerWebInterface that registers every member that inherits a common class such as WebService, and create unique instances of the members while visiting the tree from the bottom up. router.registerWebInterface!(settings, Blogs) -> creates Articles, Users, OAuth, MongoDB, Categories object instances following class members recursively, registers them to route, settings could have an opIndex that loads from (SDLang-D? JSON/w comments?) files in a config folder with opIndexAssign to override the values.

e.g. class Articles : WebService will have its members checked for WebService objects and recursively loop to register them using unique instances for the entire member tree.

s-ludwig commented 8 years ago

This works now by looking for methods that return a class or interface value. A special base class WebService isn't needed, because this is unambiguous, at least for now. I'll close this for now, although I realize that this doesn't fully overload with everything above. Please reopen if you feel that this needs further discussion.