Sha256: 147fdb595e27be48a0c9e6bce878f5ae0f9a451fdd28d7022de48adcd36de257

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

require 'faraday'

module Semlogr
  module Sinks
    module Seq
      class SeqApi
        def initialize(server_url, api_key)
          @server_url = server_url
          @api_key = api_key
        end

        def post_events(payload)
          connection = ::Faraday.new(url: @server_url) do |c|
            c.request   :retry
            c.response  :raise_error
            c.adapter   :net_http
          end

          connection.post('/api/events/raw') do |req|
            req.headers['Content-Type'] = 'application/vnd.serilog.clef'
            req.headers['X-Api-Key'] = @api_key if @api_key

            req.body = payload
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
semlogr-sinks-seq-0.1.6 lib/semlogr/sinks/seq/seq_api.rb
semlogr-sinks-seq-0.1.5 lib/semlogr/sinks/seq/seq_api.rb