lib/sham_rack/registration.rb in sham_rack-1.3.6 vs lib/sham_rack/registration.rb in sham_rack-1.4.0
- old
+ new
@@ -1,5 +1,7 @@
+require "sham_rack/allowances"
+
module ShamRack
module Registration
ADDRESS_PATTERN = /^[a-z0-9-]+(\.[a-z0-9-]+)*$/i
@@ -16,14 +18,16 @@
mount_point
end
end
def application_for(address, port = nil)
- mount_point_for(address, port).app
- end
-
- def mount(app, address, port = nil)
- at(address, port).mount(app)
+ port ||= Net::HTTP.default_port
+ mount_point_for(address, port).app.tap do |app|
+ return app unless app.nil?
+ unless ShamRack.network_connections_allowed?
+ raise NetworkConnectionPrevented, "connection to #{address}:#{port} not allowed"
+ end
+ end
end
private
def mount_point_for(address, port)