Of course you can pass data to Sinatra routes, to accept data in your routes you can add route paremeters. You can then access a params hash:
get '/hello/:name' do
# matches "GET /hello/foo" and "GET /hello/bar"
# params['name'] is 'foo' or 'bar'
"Hello #{params['name']}!"
end
You can also assign parameters directly to variables like we usually do in Ruby hashes:
get '/hello/:name' do |n|
# matches "GET /hello/foo" and "GET /hello/bar"
# params['name'] is 'foo' or 'bar'
# n stores params['name']
"Hello #{n}!"
end
You can also add wildcard parameters without any specific names by using asteriks. They can then be accessed by using params['splat']:
get '/say/*/to/*' do
# matches /say/hello/to/world
params['splat'] # => ["hello", "world"]
end