Skip to content

Commit

Permalink
Tidy up method from changes that were missed (#2570)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTim committed Feb 26, 2021
1 parent 8c68cc1 commit 07478e1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Sources/Vapor/Responder/DefaultResponder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,19 @@ internal struct DefaultResponder: Responder {
statusCode: UInt
) {
let pathForMetrics: String
let methodForMetrics: String
if let route = request.route {
// We don't use route.description here to avoid duplicating the method in the path
pathForMetrics = "/\(route.path.map { "\($0)" }.joined(separator: "/"))"
methodForMetrics = request.method.string
} else {
// If the route is undefined (i.e. a 404 and not something like /users/:userID
// We rewrite the path and the method to undefined to avoid DOSing the
// application and any downstream metrics systems. Otherwise an attacker
// could spam the service with unlimited requests and exhaust the system
// with unlimited timers/counters
pathForMetrics = "vapor_route_undefined"
}
let methodForMetrics: String
if request.route == nil {
methodForMetrics = "undefined"
} else {
methodForMetrics = request.method.string
}
let dimensions = [
("method", methodForMetrics),
Expand Down

0 comments on commit 07478e1

Please sign in to comment.