Class: IndexTanked::IndexTank::ClientResponseMiddleware

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/index-tanked/indextank/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ClientResponseMiddleware

Returns a new instance of ClientResponseMiddleware.



54
55
56
57
# File 'lib/index-tanked/indextank/client.rb', line 54

def initialize(app)
  super
  @parser = nil
end

Instance Method Details

#on_complete(env) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/index-tanked/indextank/client.rb', line 41

def on_complete(env)
  case env[:status]
  when 200
    nil # this is the expected return code
  when 204
    nil # this is the expected return code for empty responses
  when 401
    raise InvalidApiKey
  else
    raise UnexpectedHTTPException, env[:body]
  end
end