Class BSV::Overlay::HTTPSLookupFacilitator ¶
Inherits: BSV::Overlay::LookupFacilitator
Default HTTPS-based lookup facilitator using Net::HTTP.
POSTs to +{url}/lookup+ with a JSON body and the +X-Aggregation: yes+ header, as required by the BSV Overlay Services protocol.
HTTPS is enforced by default; pass +allow_http: true+ to permit plain HTTP (useful for local development and testing).
An injectable http_client may be supplied for testing. It must respond to +#request(uri, net_http_request)+ and return an object with #code and #body.
Public Instance Methods¶
initialize(allow_http: = false, http_client: = nil) ¶
- @param
allow_http[Boolean] permit non-HTTPS URLs (default: false) - @param
http_client[#request, nil] injectable HTTP client for testing - @return [HTTPSLookupFacilitator] a new instance of HTTPSLookupFacilitator
lookup(url, question, timeout: = 5) ¶
Perform an HTTPS POST to +{url}/lookup+ and return the parsed answer. - @param url [String] base URL of the Overlay Services host - @param question [LookupQuestion] the question to send - @param timeout [Integer] request timeout in seconds (default: 5) - @raise [ArgumentError] if the URL is not HTTPS and +allow_http+ is false - @raise [RuntimeError] if the server returns a non-2xx status - @return [LookupAnswer]