Chapter 5. Understanding requests and responses

 

This chapter covers

  • Understanding the hapi.js request lifecycle
  • Using extension points
  • Examining the reply interface in depth
  • Looking at the response object
  • Dealing with handling and communicating errors

I hope by now you’ve gotten a decent feel for hapi.js. You should have picked up useful, practical skills that you can apply in building your own applications. You also should have a good grasp of the language and terms we use in hapi—things like routes, handlers, requests, responses, and so on.

It should be clear that hapi has a lot going on under the surface. How things work and fit together internally is probably still rather unclear to you. We’ve only scratched the outer surface of the framework, superficially picking and choosing a small subset of the features without seeking a profound understanding of the framework. This has been an intentional decision on my part, and I’m hoping it has been a satisfying experience, and you’re hungry for more. Now it’s time to dig a little deeper.

What are requests, really? How are they processed by hapi? In what order do things happen? What and how does your code—and the building blocks we’ve used up until now—fit into that? These are some of the questions we’ll be finding answers to in this chapter.

5.1. The request object and lifecycle

5.2. The reply interface and the response object

5.3. Dealing with errors

5.4. Summary

sitemap