Skip to content

Instantly share code, notes, and snippets.

@sam
Created February 22, 2012 05:26
Show Gist options
  • Save sam/1881677 to your computer and use it in GitHub Desktop.
Save sam/1881677 to your computer and use it in GitHub Desktop.
Harbor::Controller
require "pathname"
require Pathname(__FILE__).dirname.parent + "lib/harbor"
class Foo < Harbor::Application
class Bar < Harbor::Controller
# GET: /bar/baz
get "baz" do
response.puts "Hello World!"
end
# GET: /baz
get "/baz" do
response.puts "One of these is not like the other..."
end
# GET: /bar
get do
response.puts "It's all relative baby!"
end
# GET: /
get "/" do
response.puts "I'm Home!"
end
# GET: /bar/baz/:zed
get "baz/:zed" do |zed|
response.puts "WILDCARD!: #{zed}"
end
# GET: /categories/:category_id/posts/:post_id
get "/categories/:category_id/posts/:post_id" do |category_id, post_id|
response.puts "Looking for #{post_id} in #{category_id}..."
end
end
end
run Harbor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment