Sha256: fb004c8b0390ab9cfda33348dc79a6f47761195d5a2b2813fc85008f6a5de40e
Contents?: true
Size: 650 Bytes
Versions: 2
Compression:
Stored size: 650 Bytes
Contents
# frozen_string_literal: true require 'net/http' module ImportmapCLI module Roles # role that inject behaviour for http resources module HttpResource protected # performe a http post request def http_post(url, body, headers = { 'Content-Type' => 'application/json' }) Net::HTTP.post(url, body, headers) rescue StandardError => e raise HTTPError, "[error] unexpected transport error (#{e.class}: #{e.message})" end # check http status code and performa a block def http_status?(response, code, &block) block.call if response.code == code.to_s end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
importmap-cli-0.4.0 | lib/importmap_cli/roles/http_resource.rb |
importmap-cli-0.1.0 | lib/importmap_cli/roles/http_resource.rb |