lib/optic/middleware.rb in optic-middleware-0.1.3 vs lib/optic/middleware.rb in optic-middleware-0.2.0

- old
+ new

@@ -4,10 +4,11 @@ module Optic class DocumentingMiddleware def initialize(app, options = {}) @app = app @app.freeze + @host = ENV['OPTIC_SERVER_HOST'] || 'localhost' end def call(env) req = Rack::Request.new(env) res = @app.call(env) @@ -47,11 +48,11 @@ logging_request.content_type = req.content_type if req.content_type logging_request.body_stream.rewind end # Send request to request logging endpoint - http = Net::HTTP.new("localhost", 30334) + http = Net::HTTP.new(@host, 30334) http.verify_mode = OpenSSL::SSL::VERIFY_NONE logging_request_response = http.start do http.request(logging_request) end @@ -72,10 +73,10 @@ end logging_response.body = bodyData logging_response.content_length = bodyData.bytesize.to_s end - http = Net::HTTP.new("localhost", 30335) + http = Net::HTTP.new(@host, 30335) logging_response_response = http.start do http.request(logging_response) end end