lib/baurets/optionsful/server.rb in optionsful-0.4.0 vs lib/baurets/optionsful/server.rb in optionsful-0.4.1

- old
+ new

@@ -5,11 +5,11 @@ ## # Wakes up! # def initialize(app) @app = app - @config = Config.new + @config = Configurator.new.configure! end ## # Handle HTTP OPTIONS requests. # @@ -34,32 +34,32 @@ status = 500 body = "" unless allows.empty? headers.merge!({"Allow" => allows}) status = 204 - if @config.link == true + if @config[:link] == true headers.merge!({"Link" => build_link_header}) end else status = 404 - body = "Not found" + body = "Not found." end [status, headers, body] end def build_link_header link = "" - if @config.host == "auto" + if @config[:host] == "auto" server_name = @env["SERVER_NAME"] server_port = @env["SERVER_PORT"] link = "\"<http://#{server_name}:#{server_port}" else - link = "\"<http://#{@config.host}" + link = "\"<http://#{@config[:host]}" end - unless @config.base_path.empty? - link += @config.base_path unless @config.base_path == "/" + unless @config[:base_path].empty? + link += @config[:base_path] unless @config[:base_path] == "/" end - if @config.propagate == true + if @config[:propagate] == true link += @env["PATH_INFO"] end link += ">; type=text/html; rel=help\"" link end