Sha256: 043edef53798c95eff9259d7db5af684af227ce7b9daca2d805d73ea2a4f43ae

Contents?: true

Size: 477 Bytes

Versions: 3

Compression:

Stored size: 477 Bytes

Contents

# frozen_string_literal: true
require 'base64'

module Extension
  module Features
    module TunnelUrl
      NGROK_TUNNELS_URI = URI.parse('http://localhost:4040/api/tunnels')
      TUNNELS_FIELD = 'tunnels'
      PUBLIC_URL_FIELD = 'public_url'

      def self.fetch
        response = Net::HTTP.get_response(NGROK_TUNNELS_URI)
        json = JSON.parse(response.body)
        json.dig(TUNNELS_FIELD, 0, PUBLIC_URL_FIELD)
      rescue
        nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shopify-cli-0.9.2 lib/project_types/extension/features/tunnel_url.rb
shopify-cli-0.9.1 lib/project_types/extension/features/tunnel_url.rb
shopify-cli-0.9.0 lib/project_types/extension/features/tunnel_url.rb