Sha256: d592e0c75105dd8af645ccb6a8b30b678573cd082293c87462c9ce104d0d3d5b

Contents?: true

Size: 644 Bytes

Versions: 1

Compression:

Stored size: 644 Bytes

Contents

# frozen_string_literal: true

require "uri"
require "json"
require "httpx"

module SlackWebhookLogger
  class RequestIO
    class << self
      def close
        true
      end

      def write(hash)
        return if hash.blank?

        return if SlackWebhookLogger.ignore_patterns.any? { |ignore_pattern| hash[:text].match(ignore_pattern) }

        response = HTTPX.post(SlackWebhookLogger.webhook_uri.to_s, form: hash)

        return if (200..299).cover?(response.status)

        case response
        when HTTPX::ErrorResponse
          warn(response)
        else
          warn(response.body)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slack_webhook_logger-0.5.0 lib/slack_webhook_logger/request_io.rb