November 2018
Intermediate to advanced
404 pages
10h 16m
English
Finally, the following code demonstrates how the entry is removed:
app.router.get("/journal/remove/:index?") { request, response, next in guard let index = request.parameters["index"] else { return try response.status(.badRequest).send("Missing entry index").end() } guard let idx = Int(index) else { return try response.status(.badRequest).send("Invalid entry index").end() } if let entry = journal.delete(index: idx) { print("Deleted: Entry[\(index)]: \(entry)") try response.redirect(mainPage) } try response.status(.unprocessableEntity).end()}
The route handling process follows the similar step to decipher the URL parameter from request. Then it calls JournalController.delete() to update the deletion of that entry by ...
Read now
Unlock full access