4 ms·
I agree if everything in your app follows a perfectly restful pattern, but what about if you want to capture application state that does not belong in a databas
by paultannenbaum 13y ago
I agree if everything in your app follows a perfectly restful pattern, but what about if you want to capture application state that does not belong in a database. For example, what if you have an online store that has many different filters to narrow down selections. And you want to share this url with someone.
How would this be done using a RESTful url path? You have to use url params. If so, this seems to be a nice solution if your using a lot of params.
- NathanKP 13y agoHere is how I would do it: Assuming you were searching for computers with the following filters: Manufacturer: Apple Type: Laptop You could represent that as: http://mystore.com/electronics/computers/manufacturer/apple/type/laptop If you make your routing code (on either the frontend or the backend) robust enough then you will be able to support any number of filters in any order.
- matryer 13y agofor nested data - I 100% agree. I'd do that and use params for things like ordering or filtering on other fields: http://mystore.com/electronics/computers/manufacturer/apple/type/laptop#?order=-price&size=medium Also - the `#` is nice for when you don't want to reload the page.
- matryer 13y agoURL parameters ARE RESTful and I agree that your use case is exactly where parameters are useful.