Class: Compass::SearchController

Inherits:
ApplicationController show all
Includes:
Cors
Defined in:
app/controllers/compass/search_controller.rb

Overview

Search controller.

Instance Method Summary collapse

Methods included from Cors

#cors

Methods inherited from ApplicationController

#authenticate, #current_context, #current_context_id, #validate_context

Instance Method Details

#indexObject



8
9
10
# File 'app/controllers/compass/search_controller.rb', line 8

def index
  render json: Compass::Search.providers
end

#showObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/compass/search_controller.rb', line 12

def show
  render json: Compass::Search.search(params[:q], params[:provider_name], current_context)
rescue Compass::Search::UnknownProvider => error
  render status: :not_found, json: {
    error: error.message,
    available_providers: Compass::Search.providers.map(&:name)
  }
rescue => error
  Compass.logger&.error(
    "[ Compass::SearchController ] #{params[:provider_name]}: #{error.class}: #{error.message} | Query: #{params[:q].inspect}"
  )
  raise
end