init
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user