Created
February 27, 2013 07:33
-
-
Save brainix/5045983 to your computer and use it in GitHub Desktop.
Deprecate routes (URLs) in Sinatra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
['/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