Sha256: 4163eaa56a4343c55c4af9bd989140c988d804a8d28ae12c46d1f18a3dde41dc

Contents?: true

Size: 570 Bytes

Versions: 1

Compression:

Stored size: 570 Bytes

Contents

# frozen_string_literal: true

require "uri"
require "net/http"

module ActiveWebhook
  module Delivery
    class NetHTTPAdapter < BaseAdapter
      def status_code
        response.code.to_i
      end

      protected

      def deliver!
        uri = URI.parse(url.strip)

        request = Net::HTTP::Post.new(uri.request_uri)
        request.body = body
        headers.each { |k, v| request[k] = v }

        http = Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = uri.scheme.casecmp("https").zero?
        http.request(request)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_webhook-1.0.0 lib/active_webhook/delivery/net_http_adapter.rb