I've written a condition to enforce ssl on some pages, but during development it's set to off:
def ssl_only( _ )
condition do
if settings.ssl_on
redirect File.join("https://", request.host, request.path_info ), 301 unless request.host.start_with? 'localhost'
end
end
end
get "/login/?", :ssl_only => true do
#...
but, I've an extension with routes defined that should also use this condition. If I go ahead and add it to the extension's routes, the following error message appears:
undefined method `ssl_only' for Sinatra::Application:Class (NoMethodError)
The ssl_only method is registered in the main (modular style) app before the extension is required and registered.
I'm wondering if I need to perhaps move the ssl_only condition out into its own extension that is then registered within the main app and in the current extension? Or is there some other way to stop the no method error?
Any insight or help will be much appreciated.
Regards,
Iain