Lesson 7.4

handle composes and runs the stack

Rewrite App.handle to select middleware, compose the three bands, dispatch them, then generate OPTIONS/405/404 only when nothing responded.

28 minsrc/app.js
  • Walk the _use list to build band 1 and band 2 and resolve the route, in registration order.
  • Compose [band1, band2, band3], run dispatch, and decide the fallback from headersSent and whether a route matched.
  • Select GET before dispatch for automatic HEAD, suppress every HEAD body, and keep OPTIONS/405/404 in the fallback branch.
Locked

This chapter is part of the framework capstone. Chapters 1 and 2 are free to build - unlock the rest to keep going.

Unlock the depth