Created
November 16, 2011 19:49
-
-
Save adamlwatson/1371133 to your computer and use it in GitHub Desktop.
Workaround for multiple regex patterns against a variable parameter segment in a url mapping in Goliath
This file contains hidden or 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
class RackRoutes < Goliath::API | |
get '/item/:value/description' do | |
if params[:value].match /^[a-zA-Z][\w\-]+$/ | |
...do awesome stuff with a parameter that is alpha-based... | |
elsif params[:value].match /\d+/ | |
...do awesome stuff with a parameter that is numeric-based... | |
else | |
run Proc.new { |env| [404, {}, "" ] } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment