Class: Honeycomb::Aws::ApiHandler::S3Redirect

Inherits:
Object
  • Object
show all
Defined in:
lib/honeycomb/integrations/aws.rb

Overview

Constant Summary collapse

REGION_TAG =
%r{<Region>(.+?)</Region>}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ S3Redirect

Returns a new instance of S3Redirect.



344
345
346
# File 'lib/honeycomb/integrations/aws.rb', line 344

def initialize(context)
  @context = context
end

Instance Method Details

#happening?Boolean

Returns:

  • (Boolean)


356
357
358
# File 'lib/honeycomb/integrations/aws.rb', line 356

def happening?
  status == 400 && region && !original_host.include?("fips")
end

#original_hostObject



348
349
350
# File 'lib/honeycomb/integrations/aws.rb', line 348

def original_host
  @context.http_request.endpoint.host
end

#regionObject



360
361
362
# File 'lib/honeycomb/integrations/aws.rb', line 360

def region
  @region ||= region_from_headers || region_from_body
end

#region_from_bodyObject



368
369
370
371
# File 'lib/honeycomb/integrations/aws.rb', line 368

def region_from_body
  body = @context.http_response.body_contents
  body.match(REGION_TAG) { |tag| tag[1] }
end

#region_from_headersObject



364
365
366
# File 'lib/honeycomb/integrations/aws.rb', line 364

def region_from_headers
  @context.http_response.headers["x-amz-bucket-region"]
end

#statusObject



352
353
354
# File 'lib/honeycomb/integrations/aws.rb', line 352

def status
  @context.http_response.status_code
end