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.
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 yourself. This section attempts to shore up that understanding with a more in-depth examination of routing, including routing features and approaches you haven’t seen yet.