Skip to Content
Web Development with Node and Express
book

Web Development with Node and Express

by Ethan Brown
July 2014
Intermediate to advanced
329 pages
8h 50m
English
O'Reilly Media, Inc.
Content preview from Web Development with Node and Express

Chapter 14. Routing

Routing is one of the most important aspects of your website or web service; fortunately, routing in Express is simple, flexible, and robust. Routing is the mechanism by which requests (as specified by a URL and HTTP method) are routed to the code that handles them. As we’ve already noted, routing used to be file based and very simple: if you put the file foo/about.html on your website, you would access it from the browser with the path /foo/about.html. Simple, but inflexible. And, in case you hadn’t noticed, having “HTML” in your URL is extremely passé these days.

Before we dive into the technical aspects of routing with Express, we should discuss the concept of information architecture (IA). IA refers to the conceptual organization of your content. Having an extensible (but not overcomplicated) IA before you begin thinking about routing will pay huge dividends down the line.

One of the most intelligent and timeless essays on IA is by Tim Berners-Lee, who practically invented the Internet. You can (and should) read it now: http://www.w3.org/Provider/Style/URI.html. It was written in 1998. Let that sink in for a minute: there’s not much that was written on Internet technology in 1998 that is just as true today as it was then.

From that essay, here is the lofty responsibility we are being asked to take on:

It is the duty of a Webmaster to allocate URIs which you will be able to stand by in 2 years, in 20 years, in 200 years. This needs thought, and organization, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Web Development with Node and Express, 2nd Edition

Web Development with Node and Express, 2nd Edition

Ethan Brown

Publisher Resources

ISBN: 9781491902288Errata Page