class Hyperb::FuncCallRequest
func requests are very simple, they do not require signing
Attributes
body[RW]
client[RW]
headers[RW]
path[RW]
query[RW]
verb[RW]
Public Class Methods
new(client, path, query = {}, verb = 'GET', body = '')
click to toggle source
# File lib/hyperb/request.rb, line 140 def initialize(client, path, query = {}, verb = 'GET', body = '') @client = client set_base_url @path = path @verb = verb @query = URI.encode_www_form(query) @body = body.empty? ? body : body.to_json @headers = { content_type: 'application/json' } end
Public Instance Methods
fail_or_return(code, body)
click to toggle source
# File lib/hyperb/request.rb, line 165 def fail_or_return(code, body) error = Hyperb::Error::ERRORS[code] raise(error.new(body, code)) if error body end
perform()
click to toggle source
# File lib/hyperb/request.rb, line 157 def perform final_url = @base_url + @path + '?' + @query options = {} options[:body] = @body unless @body.empty? response = HTTP.headers(@headers).public_send(@verb.downcase.to_sym, final_url, options) fail_or_return(response.code, response.body) end
set_base_url()
click to toggle source
# File lib/hyperb/request.rb, line 152 def set_base_url @host = "#{client.region}.hyperfunc.io".freeze @base_url = "https://#{@host}/".freeze end