Class: Apartment::Elevators::Header
- 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
-
#raw_header ⇒ Object
readonly
Returns the value of attribute raw_header.
Instance Method Summary collapse
-
#initialize(app, header: 'X-Tenant-Id', **_options) ⇒ Header
constructor
A new instance of Header.
- #parse_tenant_name(request) ⇒ Object
Methods inherited from Generic
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', **) super(app) @header_name = "HTTP_#{header.upcase.tr('-', '_')}" @raw_header = header.freeze end |
Instance Attribute Details
#raw_header ⇒ Object (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 |