httpbuilder icon indicating copy to clipboard operation
httpbuilder copied to clipboard

support relative paths

Open craffael opened this issue 7 years ago • 0 comments

A REST API endpoint often has a "baseURI" such as https://api.mailgun.net/v3. A concrete endpoint has e.g. the full URI https://api.mailgun.net/v3/abc.ch/events.

It would now be very nice if we could write:

RESTClient client = new RESTClient("https://api.mailgun.net/v3")
client.get(path: "abc.ch/events")

Unfortunately this results in a GET request to https://api.mailgun.net/abc.ch/events instead of https://api.mailgun.net/v3/abc.ch/events (the v3 is missing!).

Therefore I propose that the path of the baseURI and the provided path (from the client.get() call) are merged to create the final URI. At the moment the path of the baseURI is replaced.

I think it would be a very simple change in groovyx.net.http.URIBuilder#setPath() which I could submit myself. What do you think?

craffael avatar Mar 29 '17 18:03 craffael