Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Entrypoint module with ApiController #10880

Merged
merged 1 commit into from Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion app/controllers/api/base_controller.rb
Expand Up @@ -57,7 +57,6 @@ def set_access_control_headers
#
# Support for API Collections
#
include_concern 'Entrypoint'
include_concern 'Generic'

include_concern 'Accounts'
Expand Down
42 changes: 0 additions & 42 deletions app/controllers/api/base_controller/entrypoint.rb

This file was deleted.

36 changes: 36 additions & 0 deletions app/controllers/api_controller.rb
@@ -0,0 +1,36 @@
class ApiController < Api::BaseController
def index
res = {
:name => @name,
:description => @description,
:version => @version,
:versions => entrypoint_versions,
:settings => user_settings,
:identity => auth_identity
}
res[:authorization] = auth_authorization if attribute_selection.include?("authorization")
res[:collections] = entrypoint_collections
render_resource :entrypoint, res
end

private

def entrypoint_versions
version_config[:definitions].select(&:ident).collect do |version_specification|
{
:name => version_specification[:name],
:href => "#{@req.api_prefix}/#{version_specification[:ident]}"
}
end
end

def entrypoint_collections
collection_config.collections_with_description.sort.collect do |collection_name, description|
{
:name => collection_name,
:href => collection_name,
:description => description
}
end
end
end
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -2754,7 +2754,7 @@
# OPTIONS requests for REST API pre-flight checks
match '/api/*path' => 'api/base#handle_options_request', :via => [:options]

get '/api(/:version)' => 'api/base#show_entrypoint', :format => 'json', :version => API_VERSION_REGEX
get '/api(/:version)' => 'api#index', :format => 'json', :version => API_VERSION_REGEX

unless defined?(API_ACTIONS)
API_ACTIONS = {
Expand Down