Sha256: 5c6f43a100f21a524524a81db8f0dabc03ad2704cdb90b5fe7a9abcae4980f6b

Contents?: true

Size: 433 Bytes

Versions: 1

Compression:

Stored size: 433 Bytes

Contents

module OMCMS
  class ParseResponse < Faraday::Middleware
    def initialize(app)
      super app
      @app = app
    end

    def on_complete(response_env)
      return OMCMS::Response::Error.new(response_env) if response_env.status >= 400

      response_env.body
    rescue StandardError => e
      OMCMS::Response::Error.new(e)
    end
  end
end

Faraday::Response.register_middleware(omcms_parse_response: OMCMS::ParseResponse)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omcms-ruby-client-1.2.0 lib/omcms/middleware/parse_response.rb