Skip to content

Instantly share code, notes, and snippets.

@carllerche
Created August 23, 2008 22:47
Show Gist options
  • Save carllerche/6951 to your computer and use it in GitHub Desktop.
Save carllerche/6951 to your computer and use it in GitHub Desktop.
Merb::Router do |r|
r.match("/hello", :method => :get).to(:controller => "hello", :action => "get")
r.match("/hello", :method => :post).to(:controller => "hello", :action => "post")
r.match("/whatever").to(:controller => "whatever", :action => "index")
r.match("/world", :method => :get).to(:controller => "world", :action => "get")
r.match("/world", :method => :post).to(:controller => "world", :action => "post")
end
def match(request)
if request.method == "get"
if request.path == "/hello"
return {:controller => "hello", :action => "get"}
elsif request.path == "/whatever"
return {:controller => "whatever", :action => "index"}
elsif request.path == "/world"
return {:controller => "world", :action => "get"}
end
elsif request.method == "post"
if request.path == "/hello"
return {:controller => "hello", :action => "post"}
elsif request.path == "/whatever"
return {:controller => "whatever", :action => "index"}
elsif request.path == "/world"
return {:controller => "world", :action => "post"}
end
else
if request.path == "/whatever"
return {:controller => "whatever", :action => "index"}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment