Grokking Node.js
0% completed
Routing in Node.js Applications
What should a server do when the same program receives requests for /, /about and /user/alice? Each address needs different code, but Node.js calls one handler function for all of them. Choosing which code runs for a given method and URL is called routing, and one entry in that choice, such as "GET /about runs this function", is called a route.
This lesson builds a router for one small site without any framework. It starts with a chain of if statements, tests it against real URLs to find where it fails, and then replaces it with a route table.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%