Chapter 4. Routes and handlers in-depth

This chapter covers

  • More routing techniques
  • Server methods and prerequisites
  • Creating custom handlers
  • Uploading files

In this chapter we’ll take an in-depth look at two of the most important concepts in hapi: routes and handlers. Routes are how you tell hapi what kind of requests you’re interested in. Handlers are how you choose to respond to those routes. Having a mastery of these two will greatly broaden the types of applications you can create with hapi.

4.1. Routing in-depth

You should be familiar now with what routes are in hapi and how to create them (using server.route()). If you’ve been following along with the example projects in earlier chapters, you will have even made quite a few routes ...

Get hapi.js in Action now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.