diff options
author | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
commit | 62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch) | |
tree | c3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4 /lib/api/api.rb | |
parent | f6453eca992a9c142268e78ac782cef98110d183 (diff) | |
download | gitlab-ce-tc-standard-gem.tar.gz |
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I
decided to try https://github.com/testdouble/standard on our codebase.
It's opinionated, but at least it's a _standard_.
Diffstat (limited to 'lib/api/api.rb')
-rw-r--r-- | lib/api/api.rb | 56 |
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 |