lib/angelo/mustermann.rb in angelo-0.0.9 vs lib/angelo/mustermann.rb in angelo-0.1.0
- old
+ new
@@ -26,10 +26,15 @@
path = ::Mustermann.new path
routes[m][path] = Responder.new &block
end
end
+ def socket path, &block
+ path = ::Mustermann.new path
+ routes[:socket][path] = WebsocketResponder.new &block
+ end
+
def routes
@routes ||= {}
ROUTABLE.each do |m|
@routes[m] ||= RouteMap.new
end
@@ -42,12 +47,15 @@
@params ||= super.merge mustermann.params(request.path)
end
class RouteMap < Hash
def [] route
+ responder = nil
mustermann = keys.select {|k| k.match(route)}.first
- responder = fetch mustermann
- responder.mustermann = mustermann
+ if mustermann
+ responder = fetch mustermann
+ responder.mustermann = mustermann
+ end
responder
end
end
end