updates
This commit is contained in:
30
Sources/App/Controllers/MatchController.swift
Normal file
30
Sources/App/Controllers/MatchController.swift
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// MatchController.swift
|
||||
// App
|
||||
//
|
||||
// Created by Michael Simard on 12/13/20.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Fluent
|
||||
import Vapor
|
||||
|
||||
|
||||
|
||||
struct MatchController: RouteCollection {
|
||||
func boot(routes: RoutesBuilder) throws {
|
||||
let matchRoute = routes.grouped("cod-tracker","api", "match")
|
||||
matchRoute.delete("delete", "id",":id", use: deleteMatch)
|
||||
}
|
||||
|
||||
func deleteMatch(req: Request) throws -> EventLoopFuture<HTTPStatus> {
|
||||
guard let id = req.parameters.get("id", as: UUID.self) else {
|
||||
throw Abort(.badRequest)
|
||||
}
|
||||
return Match.find(id, on: req.db)
|
||||
.unwrap(or: Abort(.notFound))
|
||||
.flatMap { $0.delete(on: req.db) }
|
||||
.map { .ok }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user