405b82af23
* master: (51 commits) Fix version Fix specs and rubocop warnings Improve the consistency of commit titles, branch names, tag names, issue/MR titles, on their respective project pages fixed LDAP activation on login to use new ldap_blocked state Fix Admin/Users view to position buttons without spacing magic Update to Go 1.5.3 Fix the undefinded variable error in Project's safe_import_url method Update CHANGELOG [ci skip] Add some cosmetic changes to variables API documentation [ci skip] Fix misaligned edit button in milestone collection partial Update button styles for Milestones#show Modify builds API documentation style [ci skip] Modify :ci_variable factory Ensure the API doesn't return notes that the current user shouldn't see Add 'Build' prefix to Variables entry name in API docs index Fix some typos Add spec for Note#cross_reference_not_visible_for? Remove (invalid) timestamp formatting Move `BroadcastMessage#status` to a helper since it's presentational Update CHANGELOG ... Conflicts: doc/api/README.md lib/api/api.rb lib/api/entities.rb
60 lines
1.5 KiB
Ruby
60 lines
1.5 KiB
Ruby
Dir["#{Rails.root}/lib/api/*.rb"].each {|file| require file}
|
|
|
|
module API
|
|
class API < Grape::API
|
|
include APIGuard
|
|
version 'v3', using: :path
|
|
|
|
rescue_from ActiveRecord::RecordNotFound do
|
|
rack_response({ 'message' => '404 Not found' }.to_json, 404)
|
|
end
|
|
|
|
rescue_from :all do |exception|
|
|
# lifted from https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb#L60
|
|
# why is this not wrapped in something reusable?
|
|
trace = exception.backtrace
|
|
|
|
message = "\n#{exception.class} (#{exception.message}):\n"
|
|
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
|
|
message << " " << trace.join("\n ")
|
|
|
|
API.logger.add Logger::FATAL, message
|
|
rack_response({ 'message' => '500 Internal Server Error' }.to_json, 500)
|
|
end
|
|
|
|
format :json
|
|
content_type :txt, "text/plain"
|
|
|
|
helpers Helpers
|
|
|
|
mount Groups
|
|
mount GroupMembers
|
|
mount Users
|
|
mount Projects
|
|
mount Repositories
|
|
mount Issues
|
|
mount Milestones
|
|
mount Session
|
|
mount MergeRequests
|
|
mount Notes
|
|
mount Internal
|
|
mount SystemHooks
|
|
mount ProjectSnippets
|
|
mount ProjectMembers
|
|
mount DeployKeys
|
|
mount ProjectHooks
|
|
mount Services
|
|
mount Files
|
|
mount Commits
|
|
mount CommitStatus
|
|
mount Namespaces
|
|
mount Branches
|
|
mount Labels
|
|
mount Settings
|
|
mount Keys
|
|
mount Tags
|
|
mount Triggers
|
|
mount Builds
|
|
mount Variables
|
|
end
|
|
end
|