Permalink
Browse files

need to uncompile for reset, accept head for get as well

  • Loading branch information...
1 parent 51e716a commit 19977a2c810fa8b11cd11d7b3edb1c86eb0c692f @joshbuddy committed Sep 7, 2011
Showing with 4 additions and 12 deletions.
  1. +4 −12 lib/http_router.rb
View
@@ -70,6 +70,7 @@ def add(*args, &app)
route
end
+ # Same as add, but accepts only a +Route+ object.
def add_route(route)
@routes << route
route
@@ -78,18 +79,13 @@ def add_route(route)
# Adds a path that only responds to the request method +GET+.
#
# Returns the route object.
- def get(path, opts = {}, &app); add_with_request_method(path, :get, opts, &app); end
+ def get(path, opts = {}, &app); add_with_request_method(path, [:get, :head], opts, &app); end
# Adds a path that only responds to the request method +POST+.
#
# Returns the route object.
def post(path, opts = {}, &app); add_with_request_method(path, :post, opts, &app); end
- # Adds a path that only responds to the request method +HEAD+.
- #
- # Returns the route object.
- def head(path, opts = {}, &app); add_with_request_method(path, :head, opts, &app); end
-
# Adds a path that only responds to the request method +DELETE+.
#
# Returns the route object.
@@ -100,11 +96,6 @@ def delete(path, opts = {}, &app); add_with_request_method(path, :delete, opts,
# Returns the route object.
def put(path, opts = {}, &app); add_with_request_method(path, :put, opts, &app); end
- # Adds a path that only responds to the request method +OPTIONS+.
- #
- # Returns the route object.
- def options(path, opts = {}, &app); add_with_request_method(path, :options, opts, &app); end
-
# Performs recoginition without actually calling the application and returns an array of all
# matching routes or nil if no match was found.
def recognize(env)
@@ -122,6 +113,7 @@ def call(env, perform_call = true)
# Resets the router to a clean state.
def reset!
+ uncompile
@routes, @named_routes, @root = [], Hash.new{|h,k| h[k] = []}, Node::Root.new(self)
@default_app = Proc.new{ |env| ::Rack::Response.new("Your request couldn't be found", 404).finish }
end
@@ -147,7 +139,7 @@ def default(app)
# # ==> "/123.html?fun=inthesun"
def url(route, *args)
compile
- raw_url(route, *args)
+ url(route, *args)
end
alias_method :compiling_url, :url

0 comments on commit 19977a2

Please sign in to comment.