lib/plezi/handlers/http_router.rb in plezi-0.12.0 vs lib/plezi/handlers/http_router.rb in plezi-0.12.1
- old
+ new
@@ -38,10 +38,11 @@
@hosts = {}
@active_host = nil
# adds a host to the router (or activates an existing host to add new routes). accepts a host name and any parameters not related to the actual connection (ssl etc') (see {Plezi.host})
def add_host host_name, params = {}
+ (params = host_name) && (host_name = params.delete(:host)) if host_name.is_a?(Hash)
params[:index_file] ||= 'index.html'
params[:assets_public] ||= '/assets'
params[:assets_public].chomp! '/'
params[:public] ||= params[:root] # backwards compatability
host_name = (host_name.is_a?(String) ? host_name.to_s.downcase : (host_name.is_a?(Regexp) ? host_name : :default))
@@ -50,10 +51,10 @@
@active_host
end
# adds an alias to an existing host name (normally through the :alias parameter in the `add_host` method).
def add_alias host_name, *aliases
host = get_host host_name
- host ||= add_host :default
+ raise "Couldn't find requested host to add alias." unless host.
aliases.each {|a| @hosts[a.to_s.downcase] = host}
true
end
# adds a route to the active host. The active host is the last host referenced by the `add_host`.