lib/activehook/server/send.rb in activehook-0.1.4 vs lib/activehook/server/send.rb in activehook-0.1.5

- old
+ new

@@ -5,24 +5,24 @@ "User-Agent" => "ActiveHook/#{ActiveHook::VERSION}" }.freeze module Server class Send - attr_accessor :payload - attr_reader :response_time, :uri, :status, :response + attr_accessor :hook + attr_reader :response_time, :status, :response def initialize(options = {}) options.each { |key, value| send("#{key}=", value) } end def start @status = post_hook log_status end - def uri=(uri) - @uri = URI.parse(uri) + def uri + @uri ||= URI.parse(@hook.uri) end def success? @status == :success end @@ -30,11 +30,11 @@ private def post_hook http = Net::HTTP.new(uri.host, uri.port) measure_response_time do - @response = http.post(uri.path, payload, REQUEST_HEADERS) + @response = http.post(uri.path, @hook.final_payload, final_headers) end response_status(@response) rescue :error end @@ -62,9 +62,13 @@ if status == :success ActiveHook.log.info(msg) else ActiveHook.log.err(msg) end + end + + def final_headers + { "X-Hook-Signature" => @hook.signature }.merge(REQUEST_HEADERS) end end end end