Mapping URLs with Multiple Segments
The technique in the preceding section is great if you know ahead of time exactly which parameters are going to be in the URL and how many of them there are going to be. But what do you do if you don’t know how many parameters you’re going to have, or you want people to pass a list of data on the URL without using cumbersome query string syntax?
For example, let’s say that you have an application that exposes data that can have a deeply nested hierarchy and you want users to drill into that hierarchy directly from the URL. Thankfully, the URL routing engine gives us the ability to map a list of parameters. An example of such a URL might enable the user to drill down to a location geographically, such as
http://my.app.com/location/Earth/USA/NY/NYC/TimesSquare ...
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.
Read now
Unlock full access