lib/angelo/server.rb in angelo-0.0.9 vs lib/angelo/server.rb in angelo-0.1.0

- old
+ new

@@ -11,37 +11,26 @@ end def on_connection connection # RubyProf.resume connection.each_request do |request| - if request.websocket? - debug "got websocket request..." - route_websocket connection, request - else - route_request connection, request - end + meth = request.websocket? ? :socket : request.method.downcase.to_sym + route! meth, connection, request end # RubyProf.pause end private - def route_request connection, request - route! request.method.downcase.to_sym, connection, request - end - - def route_websocket connection, request - route! :socket, connection, request - end - def route! meth, connection, request rs = @base.routes[meth][request.path] if rs responder = rs.dup responder.base = @base.new responder.connection = connection responder.request = request else + Angelo.log connection, request, nil, :not_found connection.respond :not_found, DEFAULT_RESPONSE_HEADERS, NOT_FOUND end end end