Sha256: 9ab17a48d3d51f568cd95be34bee39a4e67469ad160dc31941713d717c3d2d55
Contents?: true
Size: 568 Bytes
Versions: 1
Compression:
Stored size: 568 Bytes
Contents
# frozen_string_literal: true require 'net/http' module Layers class ExternalFetcher < Shrek::Layers def call(uri: 'enter_real_uri_here.stub', path: '/', tries: 3, **options) next_layer.call(response(uri, path), options) rescue StandardError => e tries -= 1 retry if tries.positive? { json: e.message, status: :internal_server_error } end private def response(uri, path) Net::HTTP.get_response(uri, path).body # open(Rails.root.join('spec', 'fixtures', 'files', 'people_stats.json')).read end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shrek-0.2.2 | examples/tree_pruning/app/lib/layers/external_fetcher.rb |