Sha256: b221dedcacbe7fd51d0ffc9b72e469aa3a47689481f167f3886bd913c293589f

Contents?: true

Size: 620 Bytes

Versions: 7

Compression:

Stored size: 620 Bytes

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2021-2024, by Samuel Williams.

require_relative '../internet'

::Thread.attr_accessor :async_http_internet_instance

module Async
	module HTTP
		class Internet
			# The global instance of the internet.
			def self.instance
				::Thread.current.async_http_internet_instance ||= self.new
			end
			
			class << self
				::Protocol::HTTP::Methods.each do |name, verb|
					define_method(verb.downcase) do |url, headers = nil, body = nil, &block|
						self.instance.call(verb, url, headers, body, &block)
					end
				end
			end
		end
	end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
async-http-0.76.0 lib/async/http/internet/instance.rb
async-http-0.75.0 lib/async/http/internet/instance.rb
async-http-0.74.0 lib/async/http/internet/instance.rb
async-http-0.73.0 lib/async/http/internet/instance.rb
async-http-0.72.0 lib/async/http/internet/instance.rb
async-http-0.71.0 lib/async/http/internet/instance.rb
async-http-0.70.0 lib/async/http/internet/instance.rb