Class: ApiAdaptor::Headers
- Inherits:
-
Object
- Object
- ApiAdaptor::Headers
- Defined in:
- lib/api_adaptor/headers.rb
Overview
Thread-safe header management for HTTP requests
Headers are stored in thread-local storage, allowing different threads to maintain separate header contexts without interference.
Class Method Summary collapse
-
.clear_headers ⇒ Hash
Clears all headers for the current thread.
-
.headers ⇒ Hash
Returns all non-empty headers for the current thread.
-
.set_header(header_name, value) ⇒ String
Sets a header value for the current thread.
Class Method Details
.clear_headers ⇒ Hash
Clears all headers for the current thread
41 42 43 |
# File 'lib/api_adaptor/headers.rb', line 41 def clear_headers Thread.current[:headers] = {} end |
.headers ⇒ Hash
Returns all non-empty headers for the current thread
34 35 36 |
# File 'lib/api_adaptor/headers.rb', line 34 def headers header_data.reject { |_k, v| v.nil? || v.empty? } end |
.set_header(header_name, value) ⇒ String
Sets a header value for the current thread
27 28 29 |
# File 'lib/api_adaptor/headers.rb', line 27 def set_header(header_name, value) header_data[header_name] = value end |