all, i need to do this as the following
require 'sinatra'
require 'app_env'
get '/home' do
'home page'
end
get '/about' do
'about page'
end
get '/docs' do
'docs page'
end
I not sure which route will be the root route, maybe the home, about, or docs page. So, i have to set the root page in a file app_env.rb with a line like this route_map '/home' => '/' .
Now, how do i write the method/function route_map
or anything else to implement my requirement for mapping the route dynamically.
EDIT : MY ANSWER
HOMEPAGE = '/home_page'
get '/' do
status, headers, body = call! env.merge("PATH_INFO" => HOMEPAGE)
end
If you are looking to reroute requests for ‘/’ to ‘/home’ then all that you need to do is:
If you do not want to redirect you could do this:
See this for details.