This commit is contained in:
Michael Simard
2020-05-25 23:32:28 -05:00
parent ba9bfd5e6a
commit 676a55d2df
4 changed files with 27 additions and 22 deletions

View File

@@ -3,10 +3,10 @@ import Vapor
struct TodoController: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let todos = routes.grouped("todos")
let todos = routes.grouped("match")
todos.get(use: index)
todos.post(use: create)
todos.group(":todoID") { todo in
todos.group(":matchID") { todo in
todo.delete(use: delete)
}
}
@@ -21,7 +21,7 @@ struct TodoController: RouteCollection {
}
func delete(req: Request) throws -> EventLoopFuture<HTTPStatus> {
return Todo.find(req.parameters.get("todoID"), on: req.db)
return Todo.find(req.parameters.get("matchID"), on: req.db)
.unwrap(or: Abort(.notFound))
.flatMap { $0.delete(on: req.db) }
.transform(to: .ok)