Summary

In this chapter, we've introduced and looked in detail at routing in hapi. We looked at ways to add and configure routes in hapi. We've looked more in depth at the request life cycle and hapi's routing algorithm, the trade-offs they provide, how it affects our routing strategies, and where we can take advantage of them to simplify our application logic. We also looked at hapi's request object, and how it is modified throughout the request life cycle. Finally, we looked at the reply interface, how it can be extended, and how to use hapi plugins that extend the reply interface to cater to server static content and templating.

Hopefully, at this stage you have a good understanding of all the routing logic under the hood in hapi, feel comfortable adding and configuring multiple routes, and know how to add extension points to different points in hapi's request life cycle. You now have all the tools needed to create JSON APIs, static file servers, and websites using different templating language like handlebars.

In this chapter, we've also seen how to use some of the great plugins in the hapi ecosystem. In the next chapter, we will look at structuring your codebase when you have many routes and it starts getting unwieldy, using hapi's plugin API.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.71.211