3 Create your first route handler
This chapter covers
- Adding a route handler to your server
- Understanding Warp’s Filter trait
- Serializing data to JSON
- Returning a proper HTTP response
- Sending back various HTTP error codes
- Setting up the handling of CORS
In the first part of this chapter, we will set up a basic web service with all the needed tooling to serve as the baseline for our journey throughout the book. The second part will show how easy it is to implement the handling of cross-origin resource sharing (CORS) in our web server; browsers can reach us even if they are not on the same domain.
This chapter lays the groundwork for working with Warp and sets up our web server, which we will build on in the upcoming chapters. It will teach you ...
Get Rust Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.