November 2018
Intermediate to advanced
404 pages
10h 16m
English
You'll find it convenient to group all routes for JournalController together. Vapor actually offers route grouping exactly for that.
Add the following route handlers to the JournalRoutes struct in the /Sources/App/Routes/JournalRoutes.swift file you've just created:
import Vaporstruct JournalRoutes : RouteCollection { let journal = JournalController() func boot(router: Router) throws { let topRouter = router.grouped("journal") // [1] topRouter.get(use: getTotal) topRouter.post(use: newEntry) let entryRouter = router.grouped("journal", Int.parameter) // [2] entryRouter.get(use: getEntry) entryRouter.put(use: editEntry) entryRouter.delete(use: removeEntry) } // Add route handlers here // [3]
The JournalRoutes
Read now
Unlock full access