This is a simple hack to have endpoints on your Rails app composed of other actions' output. For example, you might have
/endpoints/mehbe the combined output of 2 other actions in your app.
- Add the gem to your Gemfile, e.g.:
gem 'monomyth_engine', github: 'sardaukar/monomyth-engine'
- Mount the engine on your routes file:
mount MonomythEngine::Engine, at: '/endpoints'
- Add a config file (by default looks in 'config/facades.yml') following this scheme:
facades:
one:
users: 'users#index'
posts:
route: 'posts#latest'
bottom: 5
format: 'json'
- Restart app, go to
/endpoints/one
and observe as the output of the mentioned actions is aggregated into this one.
The config file is re-parsed on every endpoint hit, so no need to reload the app for changes to occur.
Optionally, you can have an initializer:
MonomythEngine.configure do |c|
c.facade_file = 'config/facades.yml'
c.default_format = :json # not really used
end
DO NOT USE THIS CODE IN PRODUCTION. It's not even tested, and is just a hack to learn more about Rails actions and routes!!!!!11
Developed as a hack-day toy for a hack day at New Bamboo.
This project rocks and uses MIT-LICENSE.