In the Vapor framework, you can create a struct for API Routes that implements the RouteCollection protocol:
struct ApiRoutes : RouteCollection {
func boot(router: Router) throws {
let apiRouter = router.grouped("/api")
//...
}
//...
}
In the boot(route:) function, set up a router that starts with the top-level /api URI and append each route corresponding to each of your HTTP methods to the boot(route:) function:
// public routes
let publicRouter = apiRouter.grouped("/journal")
publicRouter.get("", use: getAll)
// admin routes
let adminRouter = apiRouter.grouped("/admin")
adminRouter.post(use: newEntry)
adminRouter.get(Int.parameter, use: getEntry)
adminRouter.put(Int.parameter, use: editEntry)
adminRouter.delete(Int.parameter, use: removeEntry)
Take note that you haven't specified...