REST API: Modules endpoint refactoring.

Move shared code to the parent class.