Skip to content

Instantly share code, notes, and snippets.

@adamlwatson
Created November 16, 2011 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamlwatson/1371133 to your computer and use it in GitHub Desktop.
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
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