module Legion::Extensions::Http::Runners::Http
Public Instance Methods
delete(host:, uri: '/', port: 80, **opts)
click to toggle source
# File lib/legion/extensions/http/runners/http.rb, line 78 def delete(host:, uri: '/', port: 80, **opts) conn = Faraday.new(host) do |c| c.options[:open_timeout] = settings[:options][:open_timeout] c.options[:timeout] = settings[:options][:timeout] c.port = port c.response :xml, content_type: /\bxml$/ c.response :json, content_type: /\bjson$/ end conn.delete(uri) do |req| req.params = opts[:params] unless opts[:params].nil? req.body = opts[:body] if opts.key?(:body) req.url uri end.to_hash end
get(host:, uri: '', port: 80, **opts)
click to toggle source
# File lib/legion/extensions/http/runners/http.rb, line 16 def get(host:, uri: '', port: 80, **opts) conn = Faraday.new(host) do |c| c.options[:open_timeout] = settings[:options][:open_timeout] c.options[:timeout] = settings[:options][:timeout] c.port = port c.response :xml, content_type: /\bxml$/ c.response :json, content_type: /\bjson$/ end conn.get(uri) do |req| req.params = opts[:params] unless opts[:params].nil? req.body = opts[:body] if opts.key?(:body) end.to_hash end
head(host:, uri: '/', port: 80, **opts)
click to toggle source
# File lib/legion/extensions/http/runners/http.rb, line 94 def head(host:, uri: '/', port: 80, **opts) conn = Faraday.new(host) do |c| c.options[:open_timeout] = settings[:options][:open_timeout] c.options[:timeout] = settings[:options][:timeout] c.port = port c.response :xml, content_type: /\bxml$/ c.response :json, content_type: /\bjson$/ end conn.head(uri) do |req| req.params = opts[:params] unless opts[:params].nil? req.body = opts[:body] if opts.key?(:body) req.url uri end.to_hash end
options(host:, uri: '/', port: 80, **opts)
click to toggle source
# File lib/legion/extensions/http/runners/http.rb, line 110 def options(host:, uri: '/', port: 80, **opts) conn = Faraday.new(host) do |c| c.options[:open_timeout] = settings[:options][:open_timeout] c.options[:timeout] = settings[:options][:timeout] c.port = port c.response :xml, content_type: /\bxml$/ c.response :json, content_type: /\bjson$/ end conn.options(uri) do |req| req.params = opts[:params] unless opts[:params].nil? req.body = opts[:body] if opts.key?(:body) req.url uri end.to_hash end
patch(host:, uri: '', port: 80, **opts)
click to toggle source
# File lib/legion/extensions/http/runners/http.rb, line 46 def patch(host:, uri: '', port: 80, **opts) conn = Faraday.new(host) do |c| c.options[:open_timeout] = settings[:options][:open_timeout] c.options[:timeout] = settings[:options][:timeout] c.port = port c.response :xml, content_type: /\bxml$/ c.response :json, content_type: /\bjson$/ end conn.patch(uri) do |req| req.params = opts[:params] unless opts[:params].nil? req.body = opts[:body] if opts.key?(:body) req.url uri end.to_hash end
post(host:, uri: '', port: 80, **opts)
click to toggle source
# File lib/legion/extensions/http/runners/http.rb, line 31 def post(host:, uri: '', port: 80, **opts) conn = Faraday.new(host) do |c| c.options[:open_timeout] = settings[:options][:open_timeout] c.options[:timeout] = settings[:options][:timeout] c.port = port c.response :xml, content_type: /\bxml$/ c.response :json, content_type: /\bjson$/ end conn.post(uri) do |req| req.params = opts[:params] unless opts[:params].nil? req.body = opts[:body] if opts.key?(:body) req.url uri end.to_hash end
put(host:, uri: '/', port: 80, **opts)
click to toggle source
# File lib/legion/extensions/http/runners/http.rb, line 62 def put(host:, uri: '/', port: 80, **opts) conn = Faraday.new(host) do |c| c.options[:open_timeout] = settings[:options][:open_timeout] c.options[:timeout] = settings[:options][:timeout] c.port = port c.response :xml, content_type: /\bxml$/ c.response :json, content_type: /\bjson$/ end conn.put(uri) do |req| req.params = opts[:params] unless opts[:params].nil? req.body = opts[:body] if opts.key?(:body) req.url uri end.to_hash end
status(**_opts)
click to toggle source
# File lib/legion/extensions/http/runners/http.rb, line 12 def status(**_opts) { test: true } end