Class: RailsSpotlight::Middlewares::Handlers::DirectoryIndexActionHandler

Inherits:
BaseActionHandler
  • Object
show all
Defined in:
lib/rails_spotlight/middlewares/handlers/directory_index_action_handler.rb

Constant Summary

Constants inherited from BaseActionHandler

BaseActionHandler::BaseError, BaseActionHandler::Forbidden, BaseActionHandler::NotFound, BaseActionHandler::UnprocessableEntity, BaseActionHandler::UnsupportedMediaType

Instance Attribute Summary

Attributes inherited from BaseActionHandler

#content_type, #request, #request_id

Instance Method Summary collapse

Methods inherited from BaseActionHandler

#call, #initialize

Constructor Details

This class inherits a constructor from RailsSpotlight::Middlewares::Handlers::BaseActionHandler

Instance Method Details

#executeObject

Raises:



11
12
13
14
15
16
17
18
19
# File 'lib/rails_spotlight/middlewares/handlers/directory_index_action_handler.rb', line 11

def execute
  raise Forbidden.new('File manager is disabled', code: :disabled_file_manager_settings) unless enabled?

  @result = begin
    directory_to_json(::RailsSpotlight.config.rails_root)
  rescue => e # rubocop:disable Style/RescueStandardError
    raise UnprocessableEntity.new(e.message, code: :directory_index_error)
  end
end