Shubhamjain007 / openhab

Automatically exported from code.google.com/p/openhab
0 stars 0 forks source link

REST API - Control the deep of the returned sitemap tree #54

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When request a sitemap data for a given page, it returns the whole 
tree from that page to the most deepest pages. 
Maybe we could control the deep of the returned tree by some URL parameters or 
HTTP headers?

Original issue reported on code.google.com by mishoboss on 15 Dec 2011 at 9:37

GoogleCodeExporter commented 8 years ago

Original comment by kai.openhab on 15 Dec 2011 at 9:39

GoogleCodeExporter commented 8 years ago
Thinking about it, I actually do not see a use case where one would like to 
request "the full thing".
I have thus now changed the code (committed together with issue 53) in a way, 
that sitemaps and pages only go up to links to sub-pages, but not any further. 
If the client wants more details, he can very easily follow the links in 
question.

Original comment by kai.openhab on 18 Dec 2011 at 9:42

GoogleCodeExporter commented 8 years ago
 I disagree with you Kai. In devices like mobile phones it is always better to do one network request of 20KB than 10 requests of 2KB. The overhead is big and the chance a connection fails grows.  It grows because, you may lose one/many connection responses when asking for lots of connections all together.

You may try it. Open a 1MB file with the web server, and 10 100KB files.

If it is not difficult for you I would like to have an address where I could 
get the full sitemap. for example 
http://localhost:8080/rest/sitemaps/full/sitemap. Then you could provide both 
behaviours in REST and the REST client may choose the one he/she wants to use.

Original comment by pablo.ro...@gmail.com on 19 Dec 2011 at 7:49

GoogleCodeExporter commented 8 years ago
Yes, I agree that it is better to have one big instead of many small requests.
But my point was that it is even better not having to do a big request at all, 
but only request what is required in some context.

But to offer a compromise, I have now implemented the following:
Sitemaps are now always returned in full, pages instead without further 
drilldown.

The sitemaps url (/rest/sitemaps) returns links to the sitemap and to the 
homepage of each sitemap, so that the client has the option:
http://localhost:8080/rest/sitemaps/demo (requests the full sitemap information)
http://localhost:8080/rest/sitemaps/demo/demo (requests the homepage 'demo' of 
the sitemap 'demo')

Hope this solution suits everybody :-)

Original comment by kai.openhab on 20 Dec 2011 at 6:39

GoogleCodeExporter commented 8 years ago
Perfect! :)

Original comment by pablo.ro...@gmail.com on 20 Dec 2011 at 9:05