capture original path, allow head

This commit is contained in:
Josh Hull 2011-09-24 15:18:57 -07:00
parent f5e9295fc9
commit 8912ae04cb
3 changed files with 9 additions and 3 deletions

View File

@ -38,7 +38,7 @@ TIMES = 50_000
#simple_and_dynamic_env2 = Rack::MockRequest.env_for('/greedy/controller/action/id')
#simple_and_dynamic_env3 = Rack::MockRequest.env_for('/greedy/hey.hello.html')
u.call(Rack::MockRequest.env_for('/simple')).first == 200 or raise
#5.times {
5.times {
RBench.run(TIMES) do
report "1 levels, static" do
@ -70,5 +70,5 @@ u.call(Rack::MockRequest.env_for('/simple')).first == 200 or raise
#end
end
#}
}
puts `ps -o rss= -p #{Process.pid}`.to_i

View File

@ -6,7 +6,7 @@ class HttpRouter
attr_reader :default_values, :router, :match_partially, :other_hosts, :paths, :request_methods
attr_accessor :match_partially, :router, :host, :user_agent, :name, :ignore_trailing_slash,
:path_for_generation, :path_validation_regex, :generator, :scheme
:path_for_generation, :path_validation_regex, :generator, :scheme, :original_path
def add_default_values(hash)
@default_values ||= {}

View File

@ -21,6 +21,7 @@ class HttpRouter
end
def path=(path)
@route.original_path = path
if path.respond_to?(:[]) and path[/[^\\]\*$/]
@route.match_partially = true
@route.path_for_generation = path[0..path.size - 2]
@ -64,6 +65,11 @@ class HttpRouter
self
end
def head
@route.add_request_method "HEAD"
self
end
def get
@route.add_request_method "GET"
self