Updated to Crystal 0.9.0
This commit is contained in:
parent
72390a3ebf
commit
d23eff9acc
2 changed files with 9 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
|||
require "http/server"
|
||||
require "cgi"
|
||||
require "uri"
|
||||
|
||||
class Frank::Handler < HTTP::Handler
|
||||
INSTANCE = new
|
||||
|
@ -18,15 +18,16 @@ class Frank::Handler < HTTP::Handler
|
|||
end
|
||||
|
||||
def exec_request(request)
|
||||
uri = request.uri
|
||||
components = uri.path.not_nil!.split "/"
|
||||
uri = request.resource
|
||||
components = request.path.not_nil!.split "/"
|
||||
@routes.each do |route|
|
||||
params = route.match(request.method, components)
|
||||
if params
|
||||
if query = uri.query
|
||||
CGI.parse(query) do |key, value|
|
||||
params[key] ||= value
|
||||
end
|
||||
if query = request.query
|
||||
split = query.split("=")
|
||||
key = split[0]
|
||||
value = split[1]
|
||||
params[key] ||= value
|
||||
end
|
||||
|
||||
frank_request = Request.new(request, params)
|
||||
|
|
|
@ -7,7 +7,7 @@ class Frank::Route
|
|||
|
||||
def match(method, components)
|
||||
return nil unless method == @method
|
||||
return nil unless components.length == @components.length
|
||||
return nil unless components.size == @components.size
|
||||
|
||||
params = nil
|
||||
|
||||
|
|
Loading…
Reference in a new issue