artiya4u / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

Add methods setRootUrl and setServicePath to JsonHttpClient.Builder #97

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
External references, such as a standards document, or specification?

http://javadoc.google-http-java-client.googlecode.com/hg/1.8.3-beta/com/google/a
pi/client/http/json/JsonHttpClient.Builder.html#setBaseUrl(com.google.api.client
.http.GenericUrl)

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?

All

Please describe the feature requested.

JsonHttpClient.Builder has a setBaseUrl which is a nice general-purpose way to 
set the base URL of the API.  This is often used for testing an API locally 
before publishing it.  It would be convenient to be able to do for example:

setBaseServer("localhost:8888") or
setBaseServer("test.example.com")

The idea is that this will change only the server host and port of the base URL 
but keep the rest the same.

Original issue reported on code.google.com by yan...@google.com on 3 May 2012 at 12:45

GoogleCodeExporter commented 9 years ago
I think I have a better idea.  See for example:

https://www.googleapis.com/discovery/v1/apis/bigquery/v2/rest

Note how it has a rootUrl, servicePath, and baseUrl, where baseUrl = rootUrl + 
servicePath.  There are a few features that require us to know the rootUrl and 
not just the baseUrl.  The most obvious one is Google media uploads, whose URL 
is rootUrl + "upload/" + servicePath + resourcePath.

Therefore, I propose we add new methods setRootUrl and setServicePath to 
JsonHttpClient.Builder and deprecate setBaseUrl (similarly for getters).  For 
backwards compatibility, when calling setBaseUrl we should assume that 
servicePath is always the last two URL path parts of the baseUrl, and rootUrl 
is baseUrl minus servicePath.  However, we should not rely on that assumption 
in general.

So now to use a local test server, it would be for example:

setRootUrl(new GenericUrl("http://localhost:888")) or
setRootUrl(new GenericUrl("http://test.example.com/something")) 

Original comment by yan...@google.com on 3 May 2012 at 9:36

GoogleCodeExporter commented 9 years ago
http://codereview.appspot.com/6258043/

Original comment by rmis...@google.com on 29 May 2012 at 1:38