summaryrefslogtreecommitdiff
path: root/lib/api/api.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/api.rb')
-rw-r--r--lib/api/api.rb56
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb
index bf8ddba6f0d..3b89a541ca5 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -7,61 +7,61 @@ module API
LOG_FILENAME = Rails.root.join("log", "api_json.log")
NO_SLASH_URL_PART_REGEX = %r{[^/]+}
- NAMESPACE_OR_PROJECT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze
+ NAMESPACE_OR_PROJECT_REQUIREMENTS = {id: NO_SLASH_URL_PART_REGEX}.freeze
COMMIT_ENDPOINT_REQUIREMENTS = NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(sha: NO_SLASH_URL_PART_REGEX).freeze
- USER_REQUIREMENTS = { user_id: NO_SLASH_URL_PART_REGEX }.freeze
+ USER_REQUIREMENTS = {user_id: NO_SLASH_URL_PART_REGEX}.freeze
insert_before Grape::Middleware::Error,
- GrapeLogging::Middleware::RequestLogger,
- logger: Logger.new(LOG_FILENAME),
- formatter: Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp.new,
- include: [
- GrapeLogging::Loggers::FilterParameters.new,
- GrapeLogging::Loggers::ClientEnv.new,
- Gitlab::GrapeLogging::Loggers::RouteLogger.new,
- Gitlab::GrapeLogging::Loggers::UserLogger.new,
- Gitlab::GrapeLogging::Loggers::QueueDurationLogger.new,
- Gitlab::GrapeLogging::Loggers::PerfLogger.new,
- Gitlab::GrapeLogging::Loggers::CorrelationIdLogger.new
- ]
+ GrapeLogging::Middleware::RequestLogger,
+ logger: Logger.new(LOG_FILENAME),
+ formatter: Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp.new,
+ include: [
+ GrapeLogging::Loggers::FilterParameters.new,
+ GrapeLogging::Loggers::ClientEnv.new,
+ Gitlab::GrapeLogging::Loggers::RouteLogger.new,
+ Gitlab::GrapeLogging::Loggers::UserLogger.new,
+ Gitlab::GrapeLogging::Loggers::QueueDurationLogger.new,
+ Gitlab::GrapeLogging::Loggers::PerfLogger.new,
+ Gitlab::GrapeLogging::Loggers::CorrelationIdLogger.new,
+ ]
allow_access_with_scope :api
prefix :api
- version 'v3', using: :path do
- route :any, '*path' do
- error!('API V3 is no longer supported. Use API V4 instead.', 410)
+ version "v3", using: :path do
+ route :any, "*path" do
+ error!("API V3 is no longer supported. Use API V4 instead.", 410)
end
end
- version 'v4', using: :path
+ version "v4", using: :path
before do
- header['X-Frame-Options'] = 'SAMEORIGIN'
- header['X-Content-Type-Options'] = 'nosniff'
+ header["X-Frame-Options"] = "SAMEORIGIN"
+ header["X-Content-Type-Options"] = "nosniff"
end
# The locale is set to the current user's locale when `current_user` is loaded
after { Gitlab::I18n.use_default_locale }
rescue_from Gitlab::Access::AccessDeniedError do
- rack_response({ 'message' => '403 Forbidden' }.to_json, 403)
+ rack_response({"message" => "403 Forbidden"}.to_json, 403)
end
rescue_from ActiveRecord::RecordNotFound do
- rack_response({ 'message' => '404 Not found' }.to_json, 404)
+ rack_response({"message" => "404 Not found"}.to_json, 404)
end
rescue_from ::Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError do
- rack_response({ 'message' => '409 Conflict: Resource lock' }.to_json, 409)
+ rack_response({"message" => "409 Conflict: Resource lock"}.to_json, 409)
end
rescue_from UploadedFile::InvalidPathError do |e|
- rack_response({ 'message' => e.message }.to_json, 400)
+ rack_response({"message" => e.message}.to_json, 400)
end
rescue_from ObjectStorage::RemoteStoreError do |e|
- rack_response({ 'message' => e.message }.to_json, 500)
+ rack_response({"message" => e.message}.to_json, 500)
end
# Retain 405 error rather than a 500 error for Grape 0.15.0+.
@@ -75,7 +75,7 @@ module API
end
rescue_from Gitlab::Auth::TooManyIps do |e|
- rack_response({ 'message' => '403 Forbidden' }.to_json, 403)
+ rack_response({"message" => "403 Forbidden"}.to_json, 403)
end
rescue_from :all do |exception|
@@ -168,8 +168,8 @@ module API
mount ::API::Version
mount ::API::Wikis
- route :any, '*path' do
- error!('404 Not Found', 404)
+ route :any, "*path" do
+ error!("404 Not Found", 404)
end
end
end