Skip to content

Instantly share code, notes, and snippets.

@brainix
Created February 27, 2013 07:33
Show Gist options
  • Save brainix/5045983 to your computer and use it in GitHub Desktop.
Save brainix/5045983 to your computer and use it in GitHub Desktop.
Deprecate routes (URLs) in Sinatra
['/old', '/old2'].each do |path|
get path do
# Deprecated: Please call `/new` instead.
warn "[DEPRECATION] `#{path}` is deprecated. Please call `/new` instead."
url = '/new'
url += "?#{request.query_string}" unless request.query_string.empty?
redirect to(url), 301
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment