November 2018
Intermediate to advanced
404 pages
10h 16m
English
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.swiftimport Vapor/// Register your application's routes here.public func routes(_ router:// Basic "Hello, world!" examplerouter.get("hello") { req in // [1]return "Hello, world!"}// Example of configuring a controllerlet 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 ...
Read now
Unlock full access