Sha256: 12822b94c137a86fdcde10aa98bc6cdad0a148c974337854d5fd7d6490a48328
Contents?: true
Size: 1.04 KB
Versions: 9
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require "json" require "net/http" require "uri" module Mihari module Emitters class Webhook < Base # @return [true, false] def valid? webhook_url? end def emit(title:, description:, artifacts:, source:, tags:) return if artifacts.empty? uri = URI(Mihari.config.webhook_url) data = { title: title, description: description, artifacts: artifacts.map(&:data), source: source, tags: tags } if use_json_body Net::HTTP.post(uri, data.to_json, "Content-Type" => "application/json") else Net::HTTP.post_form(uri, data) end end private def configuration_keys %w[webhook_url] end def webhook_url @webhook_url ||= Mihari.config.webhook_url end def webhook_url? !webhook_url.nil? end def use_json_body @use_json_body ||= Mihari.config.webhook_use_json_body end end end end
Version data entries
9 entries across 9 versions & 1 rubygems