Class: LoogiHttp::Middleware::AcceptJson

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/loogi_http/middleware/request/accept_json.rb

Overview

Faraday middleware to set ‘Accept` header to `application/json`.

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Faraday::Response

Set the ‘Accept` header to `application/json`. Overwrites existing header.

Parameters:

  • env (Faraday::Env)

Returns:

  • (Faraday::Response)


12
13
14
15
16
# File 'lib/loogi_http/middleware/request/accept_json.rb', line 12

def call(env)
  headers = env[:request_headers]
  headers['Accept'] = 'application/json'
  @app.call env
end