The routes used in configure() to register routing service are declared in the routes() function in routes.swift. You're expected to put all of your routes in this centralized place:
// File: /Sources/App/routes.swift
import Vapor
/// Register your application's routes here.
public func routes(_ router:
// Basic "Hello, world!" example
router.get("hello") { req in // [1]
return "Hello, world!"
}
// Example of configuring a controller
let todoController = TodoController() // [2]
router.get("todos", use: todoController.index) // [3]
router.post("todos", use: todoController.create) // [4]
router.delete("todos", Todo.parameter, use: todoController.delete) // [5]
}
The preceding sample code shows different ways of handling routes:
- A basic endpoint is provided
- TodoController is instantiated...