Class: Linzer::Message::Adapter::Rack::Request

Inherits:
Abstract
  • Object
show all
Includes:
Common
Defined in:
lib/linzer/message/adapter/rack/request.rb

Overview

Adapter for Rack::Request objects.

Handles the Rack-specific header naming conventions (HTTP_* prefix, uppercase, underscores).

Instance Method Summary collapse

Methods inherited from Abstract

#[], #attached_request?, #field?, #request?, #response?

Constructor Details

#initialize(operation, **options) ⇒ Request

Creates a new Rack request adapter.

Parameters:

  • operation (::Rack::Request)

    The Rack request

  • options (Hash)

    Additional options (unused)



17
18
19
20
21
# File 'lib/linzer/message/adapter/rack/request.rb', line 17

def initialize(operation, **options)
  @operation = operation
  validate
  freeze
end

Instance Method Details

#attach!(signature) ⇒ ::Rack::Request

Attaches a signature to the request.

Parameters:

  • signature (Signature)

    The signature to attach

Returns:

  • (::Rack::Request)

    The request with signature headers



33
34
35
36
37
38
# File 'lib/linzer/message/adapter/rack/request.rb', line 33

def attach!(signature)
  signature.to_h.each do |h, v|
    @operation.set_header(rack_header_name(h), v)
  end
  @operation
end

#header(name) ⇒ String?

Retrieves a header value by name.

Parameters:

  • name (String)

    The header name (e.g., “content-type”)

Returns:

  • (String, nil)

    The header value



26
27
28
# File 'lib/linzer/message/adapter/rack/request.rb', line 26

def header(name)
  @operation.get_header(rack_header_name(name))
end