Skip to content
This repository has been archived by the owner on Jan 23, 2018. It is now read-only.

Commit

Permalink
Move route method.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Nov 9, 2012
1 parent 69b962c commit 82ced0c
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions lib/sokoban/receiver.rb
Expand Up @@ -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
# ---------------------------------
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 82ced0c

Please sign in to comment.