Class: Compass::InfoController

Inherits:
ApplicationController show all
Defined in:
app/controllers/compass/info_controller.rb

Overview

Info controller.

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate, #current_context, #current_context_id, #validate_context

Instance Method Details

#authObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/compass/info_controller.rb', line 15

def auth
  expiration = Compass.config.client.auth_expires_at&.call(**current_context)
  token = Compass.config.client.auth_token&.call(**current_context)

  if expiration&.future?
    expires_in(expiration - Time.now)
  else
    expires_now
  end

  if token.present?
    render json: { Authorization: "Bearer #{token}" }
  else
    render json: {}
  end
end

#indexObject



8
9
10
11
12
13
# File 'app/controllers/compass/info_controller.rb', line 8

def index
  render json: {
    version: Compass::VERSION,
    backends: Compass.config.client.backends
  }
end