Sha256: 91fc09e7998efa3572a0c5cf344a753265c2cd639b2313a822176dfe50bf3454
Contents?: true
Size: 738 Bytes
Versions: 1
Compression:
Stored size: 738 Bytes
Contents
# frozen_string_literal: true require 'uri' require 'net/http' require_relative 'const' module SimpleHelper module Http class << self SimpleHelper::Const.supported_methods.each do |key, http_method| define_method key.to_s do |uri, params, headers| http = Net::HTTP.new(uri.host, uri.port) req = http_method.new(uri, headers) req.body = params.to_json http.request(req) rescue Timeout::Error || Net::OpenTimeout puts "\e[31mTime out!\e[0m" rescue Net::HTTPBadResponse || SocketError puts "\e[31mRequest Failed!\e[0m" rescue StandardError puts "\e[31mAn unknown error occurred!\e[0m" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_request-0.1.1 | lib/simple_helper/http.rb |