In my plugin, I have a route like this in config/routes.rb
:
Pfaffmanager::Engine.routes.draw do
get "/ssh-key/:hostname" => "serverkeys#get_pub_key_by_hostname", constraints: { end
And I can do
curl https://www.pfaffmanager.com/pfaffmanager/ssh-key/test.myforum.us
and get the public key like I want.
Not willing to leave good enough alone (and users will almost certainly copy/paste this, so 9 extra characters means nothing), I want to be able to do
curl https://www.pfaffmanager.com/ssh-key/test.myforum.us
I’ve looked at a bunch of other plugins, and it seems like something like this should work:
Discourse::Application.routes.prepend do
get "/ssh-key/:hostname" => "serverkeys#get_pub_key_by_hostname", constraints: { hostname: /[^\/]+/ }
end
This doesn’t work at all. A couple things that I have tried (I’ve tried a bunch of things, and really shouldn’t have spent any time on this particular windmill) have looked like they were catching the route correctly, but then I’d need to do . . . something . . . to tell it to look for that controller in pfaffmanager/get_pub_key_by_name
.