Class: Apartment::Elevators::Header

Inherits:
Generic
  • Object
show all
Defined in:
lib/apartment/elevators/header.rb

Overview

Tenant from HTTP header. For infrastructure that injects tenant identity at the edge (CloudFront, Nginx, API gateway).

The trusted: flag is consumed by the Railtie for a boot-time warning; the elevator itself behaves identically regardless of trust level.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Generic

#call

Constructor Details

#initialize(app, header: 'X-Tenant-Id', **_options) ⇒ Header

Returns a new instance of Header.



15
16
17
18
19
# File 'lib/apartment/elevators/header.rb', line 15

def initialize(app, header: 'X-Tenant-Id', **_options)
  super(app)
  @header_name = "HTTP_#{header.upcase.tr('-', '_')}"
  @raw_header = header.freeze
end

Instance Attribute Details

#raw_headerObject (readonly)

Returns the value of attribute raw_header.



13
14
15
# File 'lib/apartment/elevators/header.rb', line 13

def raw_header
  @raw_header
end

Instance Method Details

#parse_tenant_name(request) ⇒ Object



21
22
23
# File 'lib/apartment/elevators/header.rb', line 21

def parse_tenant_name(request)
  request.get_header(@header_name).presence
end