Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning when registering HEAD routes for GET requests #2617

Merged
merged 2 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions Sources/Development/routes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public func routes(_ app: Application) throws {

return done.futureResult
}

app.get("test", "head") { req -> String in
return "OK!"
}

app.post("test", "head") { req -> String in
return "OK!"
}

app.post("login") { req -> String in
let creds = try req.content.decode(Creds.self)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Vapor/Responder/DefaultResponder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal struct DefaultResponder: Responder {
// If the route isn't explicitly a HEAD route,
// and it's made up solely of .constant components,
// register a HEAD route with the same path
if route.method != .HEAD &&
if route.method == .GET &&
route.path.allSatisfy({ component in
if case .constant(_) = component { return true }
return false
Expand Down