Chapter 3: Rocket Requests and Responses
We will discuss Rocket requests and responses more in this chapter. The first section will discuss how Rocket handles incoming requests in the form of routes. We will learn about various parts of a route including HTTP methods, URIs, and paths. Then, we will create an application that uses various parts in routes. We will also talk about Rust traits and implement a Rust trait to create a request handler.
We are also going to discuss responses in a Rocket route handler and implement returning responses. After that, we will talk more about various built-in responder implementations and learn how to create an error handler to create a custom error when a route handler fails. Finally, we will implement a generic error handler to handle common HTTP status codes such as 404
and 500
.
By the end of the chapter, you will be able to create the most important part of the Rocket framework: functions to handle incoming requests and return responses...