Chapter 5: Building Response Handlers
Up until this point, our applications have largely been reactive. We have worked on different parts of web applications to learn how to manage the incoming HTTP request. If we imagine the HTTP request/response cycle as a conversation, so far, we have been only listening. Our applications have been built to hear what the incoming client has to say.
Now, it is our turn to talk. In this chapter, we will begin to explore different facets of the HTTP response. Just as we began our learning of the HTTP request by looking at a raw request object, we will look at the raw response. It looks nearly identical and, by now, should be familiar. We will go on to explore some of the powerful tools that Sanic has to offer. Of course, there are mechanisms for JSON and HTML responses, which are probably the most popular types of content to be delivered on the web today. However, Sanic has an advantage by being an async framework: it is super easy to implement...