To avoid receiving an error when you attempt to access one of your routes and accidentally leave a trailing slash on the URL, you can use Rack::Rewrite to redirect the browser to the same URL without the trailing slash.
First add the gem to your Gemfile
gem 'rack-rewrite', '~> 1.5.0'
Run bundle install
Add
require 'rack/rewrite'
to config/environment.rb
Now add
use Rack::Rewrite do
r301 %r{^/(.*)/$}, '/$1'
end
to config/environment.rb
Restart your Sinatra app and test in your browser.
But this would lead to duplicate content in search engines, because
/my/path
and/my/path/
ARE different URLs, so the way to go is to provide a permanent, 301 redirect.