Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get root from HttpClient which is published from ServiceDiscovery #61

Open
nirajmchauhan opened this issue Apr 17, 2017 · 4 comments

Comments

@nirajmchauhan
Copy link

When we publish an HTTPEndPoint record, we pass an argument named as root. This root is not accessed when we getRecord.

Publishing record:

ServiceDiscovery discovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions()
        .setBackendConfiguration(
                new JsonObject()
                        .put("host", "127.0.0.1")
                        .put("key", "record")
        ));
discovery.publish(HttpEndpoint.createRecord(
        "users",
        "localhost", HTTP_PORT,
        "/v1/api/"),
        ar -> {
            if (ar.succeeded()) {
                System.out.println("Tweets API published");
            } else {
                System.out.println("Unable to publish the Tweets API: " +
                        ar.cause().getMessage());
            }
        });

Getting Record:

HttpEndpoint.getClient(serviceDiscovery, new JsonObject().put("name", "users"), record -> {
                        if(!record.failed()){
                            HttpClient client = record.result();
                            client.get("/v1/api/users", response ->{
                                response.bodyHandler(body -> operation.complete(body.toString()));
                            }).exceptionHandler(operation::fail)
                                    .end();
                        }
                    });
@cescoffier
Copy link
Member

Unfortunately, so far neither the HttpClient nor the WebClient allows setting a "root" url. You should be able to retrieve the root from the record if you use the getService methods.

@nirajmchauhan
Copy link
Author

Any roadmap of getting this integrated with HTTPClient? Because for now the root is useless for HTTPEndPoint. Also it is a very useful feature to have

@cescoffier
Copy link
Member

@vietj WDYT ?

@nirajmchauhan
Copy link
Author

nirajmchauhan commented Aug 14, 2017

Any update on this? Does vert.x 3.5 has this fixed?
@vietj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants