Permalink
Browse files

Move route method.

  • Loading branch information...
1 parent 69b962c commit 82ced0cfc25e8db8e98a30605dcbc55dfb4028d9 @technomancy committed Nov 8, 2012
Showing with 18 additions and 18 deletions.
  1. +18 −18 lib/sokoban/receiver.rb
View
@@ -39,10 +39,25 @@ def call(env)
@req.path_info)
Dir.chdir(@repo_dir) do
- self.send(method || :not_found)
+ self.send(method)
end
end
+ def route(req_method, req_path)
+ ROUTES.each do |method, handler, matcher, rpc|
+ if m = matcher.match(req_path)
+ if method == req_method
+ path = m[1]
+ file = req_path.sub(path + '/', '')
+ return [handler, path, file, rpc]
+ else
+ return [:not_allowed]
+ end
+ end
+ end
+ :not_found
+ end
+
# ---------------------------------
# actual command handling functions
# ---------------------------------
@@ -63,9 +78,9 @@ def service_rpc
@res.write block # steam it to the client
end
end
- else
- not_allowed
end
+ else
+ not_allowed
end
end
@@ -169,21 +184,6 @@ def get_service_type
service_type.gsub('git-', '')
end
- def route(req_method, req_path)
- ROUTES.each do |method, handler, matcher, rpc|
- if m = matcher.match(req_path)
- if method == req_method
- path = m[1]
- file = req_path.sub(path + '/', '')
- return [handler, path, file, rpc]
- else
- return [:not_allowed]
- end
- end
- end
- nil
- end
-
def content_type_matches?(rpc)
@req.content_type == "application/x-git-%s-request" % rpc
end

0 comments on commit 82ced0c

Please sign in to comment.