Reduces code duplication in ApiControllers.

Methods for controller name changes in before filters (for permission
checks) now generated dynamically, class methods moved to their own
module.