The whole controller

Block until the image is ready, then redirect

class Domains::ImagesController < ActionController::API
  def show
    # Block until the screenshot is ready
    @rendition = Website::DomainRenditionJob
      .render(@page, consumer:)

    # Serve the image
    redirect_to_storage_url @rendition.screenshot
  rescue Website::Page::RenderTimeout
    head :service_unavailable
  end
end
15 / 45