Define a route in a plugin
Closed this issue · 3 comments
I'm searching for a short example on how to define a route inside a plugin. What I want is about this:
module Roda::RodaPlugins
module Portier
module ClassMethods
def route(*args, &block)
super do |r|
r.get 'test' do
'rest'
end
end
super(&block)
end
end
end
register_plugin(:portier, Portier)
end
Only that this approach does not work, I assume because the second call to super overwrites the first. The app that calls this plugin can define routes (I assume because super(&block)
works as it should), but GET "/test"
returns nothing.
You could try using:
super do |r|
r.get 'test' do
'rest'
end
instance_exec(r, &block)
end
As this is not a bug in Roda but a question about how to use Roda, per the contribution guidelines, please ask such questions on the ruby-roda Google Group. GitHub Issues should only be used to report bugs in Roda itself.
Sorry about that. I even searched for a different support medium (the IRC channel would have been great to notice). May I kindly suggest adding a "Support" paragraph to the docs, and maybe also the main homepage and the end of the readme? That's where I looked before posting here.
Thank you for the code! It works perfectly fine.
The Google Group and IRC channel are mentioned near the top of the README, which also indicates that GitHub Issues is for bugs (http://roda.jeremyevans.net/rdoc/files/README_rdoc.html#label-Resources). This is also mentioned on the development page (http://roda.jeremyevans.net/development.html) and in the contribution guidelines that are linked from the New Issue page. GitHub used to give more emphasis to the contribution guidelines, but apparently that has been toned down.