BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c28b0a53
Commit
c28b0a53
authored
Jan 04, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't instrument 405 Grape calls
Fixes #26051. Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
8ab94120
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
3 deletions
+25
-3
26051-fix-missing-endpoint-route-method.yml
...gs/unreleased/26051-fix-missing-endpoint-route-method.yml
+4
-0
api.rb
lib/api/api.rb
+5
-1
api.rb
lib/ci/api/api.rb
+10
-0
rack_middleware.rb
lib/gitlab/metrics/rack_middleware.rb
+6
-2
No files found.
changelogs/unreleased/26051-fix-missing-endpoint-route-method.yml
0 → 100644
View file @
c28b0a53
---
title
:
Don't instrument 405 Grape calls
merge_request
:
8445
author
:
lib/api/api.rb
View file @
c28b0a53
...
...
@@ -14,7 +14,11 @@ module API
end
# Retain 405 error rather than a 500 error for Grape 0.15.0+.
# See: https://github.com/ruby-grape/grape/commit/252bfd27c320466ec3c0751812cf44245e97e5de
# https://github.com/ruby-grape/grape/blob/a3a28f5b5dfbb2797442e006dbffd750b27f2a76/UPGRADING.md#changes-to-method-not-allowed-routes
rescue_from
Grape
::
Exceptions
::
MethodNotAllowed
do
|
e
|
error!
e
.
message
,
e
.
status
,
e
.
headers
end
rescue_from
Grape
::
Exceptions
::
Base
do
|
e
|
error!
e
.
message
,
e
.
status
,
e
.
headers
end
...
...
lib/ci/api/api.rb
View file @
c28b0a53
...
...
@@ -8,6 +8,16 @@ module Ci
rack_response
({
'message'
=>
'404 Not found'
}.
to_json
,
404
)
end
# Retain 405 error rather than a 500 error for Grape 0.15.0+.
# https://github.com/ruby-grape/grape/blob/a3a28f5b5dfbb2797442e006dbffd750b27f2a76/UPGRADING.md#changes-to-method-not-allowed-routes
rescue_from
Grape
::
Exceptions
::
MethodNotAllowed
do
|
e
|
error!
e
.
message
,
e
.
status
,
e
.
headers
end
rescue_from
Grape
::
Exceptions
::
Base
do
|
e
|
error!
e
.
message
,
e
.
status
,
e
.
headers
end
rescue_from
:all
do
|
exception
|
handle_api_exception
(
exception
)
end
...
...
lib/gitlab/metrics/rack_middleware.rb
View file @
c28b0a53
...
...
@@ -70,8 +70,12 @@ module Gitlab
def
tag_endpoint
(
trans
,
env
)
endpoint
=
env
[
ENDPOINT_KEY
]
path
=
endpoint_paths_cache
[
endpoint
.
route
.
request_method
][
endpoint
.
route
.
path
]
trans
.
action
=
"Grape#
#{
endpoint
.
route
.
request_method
}
#{
path
}
"
# endpoint.route is nil in the case of a 405 response
if
endpoint
.
route
path
=
endpoint_paths_cache
[
endpoint
.
route
.
request_method
][
endpoint
.
route
.
path
]
trans
.
action
=
"Grape#
#{
endpoint
.
route
.
request_method
}
#{
path
}
"
end
end
private
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment