Ah, I see. Understandable :) I took a quick look at the source code, and it looks like both `using` methods set a value and return itself so I'd say that it's safe (and likely expected), to use the builder in this way.
This fluent builder pattern is pretty common for configuring and creating components in DW so you'll probably see that in other places, too. On Wednesday, October 17, 2018 at 10:06:43 AM UTC-7, [email protected] wrote: > > Thanks, I saw that, but I did not understand or trust that page was all > there was. > > Is it okay when using HttpClientBuilder to cascade a couple of uses of > *using()*? Like so: > > CredentialsProvider credsProvider = new BasicCredentialsProvider(); > credsProvider.setCredentials( > new AuthScope(proxyConfig.getHost(), proxyConfig.getPort()), > new UsernamePasswordCredentials("username", "password") > ); > > final HttpClient apiHttpClient = new HttpClientBuilder(env) > .using(config.getHttpClient()) > .using(credsProvider) > .build("client"); > > > > On Tuesday, October 16, 2018 at 5:54:12 PM UTC-4, Dimas Guardado wrote: >> >> Hello! >> >> Have you seen the documentation for the dropwizard-client module? If >> you're having trouble setting up a usable HTTP client, there's some sample >> code there to get you started: >> >> https://www.dropwizard.io/1.3.5/docs/manual/client.html >> >> Either client should give you what you need to make a request to your >> 3rd-party API -- Execute an HTTP method for a given URI, add an >> Authorization header, possibly with some request params/request body. >> >> The documentation assumes you know (or can find) how to use the Apache >> Http Client or Jersey Client once given an instance, though, so you might >> want to look at the docs for those libraries if you haven't used them >> before. >> >> Does that help? >> >> >> >> >> On Tuesday, October 16, 2018 at 12:04:55 PM UTC-7, [email protected] >> wrote: >>> >>> Hey folks, >>> >>> I'm new to DropWizard (1.3.7) and I am having trouble figuring out how >>> to implement a solution I want. >>> >>> I am creating a microservice to act as the middle man between a >>> third-party service (like GitHub, ie: API cannot be changed) and my webapp >>> client. >>> >>> When the client makes a call like GET /users/, once my service receives >>> the GET call will need to make a REST call to the third-party service (like >>> GitHub). >>> >>> >>> I haven't been able to figure out how to make a REST call from the >>> backend to the third-party service. The REST call requires including a >>> Authorization header before submitting to the third-party. >>> >>> >>> I have looked at HttpClient and I looked at the Dropwizard >>> Configuration Reference, but I am just not sure where to start. >>> >>> Do I look at Jersey (or some other library bundled with Dropwizard) and >>> how they do it or does DropWizard have a support for this built in? >>> >> -- You received this message because you are subscribed to the Google Groups "dropwizard-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
