- Hands-On Server-Side Web Development with Swift
- Angus Yeung
- 145字
- 2021-06-10 19:00:24
Setting Up Routes and Controllers
This chapter dives into the details of handling custom requests with routes and controllers. A route in a web framework is an object used to represent a custom request embedded in a URL, and a controller is the component that contains the business logic to handle the request routed to it. You'll learn how to add custom routes for requests, create controllers to handle the routes, and construct responses for the requests. You'll manipulate custom parameter types and process a group of routes in a collection. Finally, you'll learn how to take advantage of the Codable an class in Swift to encode and decode complex JavaScript Object Notation (JSON) objects in easy way.
Let's take a look at the topics covered in this chapter:
- Adding custom routes in a Vapor project
- Adding custom routes in a Kitura project