Use relative URL in rest/sitemaps/events/subscribe or not ? #4859
Comments
As I am fixing the sitemap SSE API at the moment to make it easily usable, it is certainly the right time to fix that issue too, even if it will break the API and require a little change in all API consumer to handle a relative or absolute path. |
I have a doubt because absolute URLs are used in all the sitemap REST API. Why should it be a relative path only for one particular API ? |
As there was no feedback, I assume using absolute path is expected. |
Sorry, that you never received any comments. WRT reverse proxies I would assume that URLs have to be relative to be resolved. |
@maggu2810 @kaikreuzer : I played with the REST API and I discovered that absolute URLs are returned in several places:
As you can see, this is not something specific to the sitemaps REST API. In particular, the items REST API has the same "philosophy". So is it something to change ? |
As written above, I would prefer relative URLs so it works for certain reverse proxy configurations, too. Yes, this would be a really major API break. |
Hi @lolodomo, to make it short, it is either a matter of making it simpler for API clients. or for whoever is configuring the (proxy) servers. Long answer: this "philosophy" issue is indeed a recurring discussion on REST API design. Many people do recommend an absolute URI to be returned to clients, for instance: The second link gives the following reasoning for this choice:
The Java URI implementation makes it relatively easy to resolve relative URLs, but that might not be the case for every client that might be using the ESH APIs. In any case, it requires some extra logic to be added on the client side. On another hand, in the JSON API forum someone mentioned the following:
This is exactly the issue that triggered the discussion on the openHAB forum. We either have people adjusting the configuration on their proxy servers to properly forward the host header, or we break the API and give clients the extra burden of resolving the URLs. Given that we have not more than a handful officially supported clients, but thousands of openHAB deployments behind different proxy setups, I would vote for changing the APIs and the clients. Still, that's a big decision that definitely needs to be discussed by the senior members here. |
Originally declared in openHAB repo: openhab/openhab-distro#442
The text was updated successfully, but these errors were encountered: