Class: Ashikawa::Core::XArangoVersion

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/ashikawa-core/x_arango_version.rb

Overview

Sets the ArangoDB API compatibility header

Constant Summary collapse

HEADER =

The name of the x-arango-version header field

'X-Arango-Version'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ XArangoVersion

Initializes the middleware

Parameters:

  • app (Callable)

    The faraday app



13
14
15
# File 'lib/ashikawa-core/x_arango_version.rb', line 13

def initialize(app)
  super(app)
end

Instance Method Details

#call(env) ⇒ Object

Sets the ‘x-arango-version` for each request



18
19
20
21
# File 'lib/ashikawa-core/x_arango_version.rb', line 18

def call(env)
  env[:request_headers][HEADER] = Ashikawa::Core.api_compatibility_version
  @app.call(env)
end