Closed nirajmchauhan closed 7 years ago
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(); } });
can you move this issue to this repository instead https://github.com/vert-x3/vertx-service-discovery ? thanks
Done.
When we publish an HTTPEndPoint record, we pass an argument named as root. This root is not accessed when we getRecord.
Publishing record:
Getting Record: