Module: UniversalRenderer::Client::Stream::Setup

Included in:
UniversalRenderer::Client::Stream
Defined in:
lib/universal_renderer/client/stream/setup.rb

Class Method Summary collapse

Class Method Details

.build_stream_request_components(body, config) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/universal_renderer/client/stream/setup.rb', line 11

def self.build_stream_request_components(body, config)
  # Ensure ssr_url is present, though ensure_ssr_server_url_configured? should have caught this.
  # However, direct calls to this method might occur, so a check or reliance on config.url is important.
  raise ArgumentError, "SSR URL is not configured." if config.url.blank?

  parsed_ssr_url = URI.parse(config.url)
  stream_uri = URI.join(parsed_ssr_url, config.stream_path)

  http = HttpPool.client(stream_uri, config.timeout)

  http_request =
    Net::HTTP::Post.new(
      stream_uri.request_uri,
      "Content-Type" => "application/json"
    )

  http_request.body = body.to_json

  [stream_uri, http, http_request]
end

.ensure_ssr_server_url_configured?(config) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/universal_renderer/client/stream/setup.rb', line 7

def self.ensure_ssr_server_url_configured?(config)
  config.url.present?
end