Search in sources :

Example 1 with HttpClient

use of org.projectnessie.client.http.HttpClient in project nessie by projectnessie.

the class AbstractRest method init.

protected void init(URI uri) {
    NessieApiV1 api = HttpClientBuilder.builder().withUri(uri).build(NessieApiV1.class);
    ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
    HttpClient.Builder httpClient = HttpClient.builder().setBaseUri(uri).setObjectMapper(mapper);
    httpClient.addResponseFilter(new NessieHttpResponseFilter(mapper));
    init(api, httpClient, uri);
}
Also used : NessieHttpResponseFilter(org.projectnessie.client.rest.NessieHttpResponseFilter) HttpClient(org.projectnessie.client.http.HttpClient) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) NessieApiV1(org.projectnessie.client.api.NessieApiV1)

Example 2 with HttpClient

use of org.projectnessie.client.http.HttpClient in project nessie by projectnessie.

the class TestJerseyRestNaiveClientInMemory method init.

@Override
protected void init(NessieApiV1 api, @Nullable HttpClient.Builder httpClient, URI uri) {
    assumeThat(httpClient).isNotNull();
    // Intentionally remove the `Accept` header from requests.
    // Service endpoints should declare the content type for their return values,
    // which should allow the Web Container to properly format output even in the absence
    // of `Accept` HTTP headers.
    RequestFilter noAcceptFilter = context -> context.removeHeader(HEADER_ACCEPT);
    httpClient.addRequestFilter(noAcceptFilter);
    api = HttpClientBuilder.builder().withAuthentication((HttpAuthentication) client -> client.addRequestFilter(noAcceptFilter)).withUri(httpClient.getBaseUri()).build(NessieApiV1.class);
    super.init(api, httpClient, uri);
}
Also used : HttpClientBuilder(org.projectnessie.client.http.HttpClientBuilder) Assumptions.assumeThat(org.assertj.core.api.Assumptions.assumeThat) HttpAuthentication(org.projectnessie.client.http.HttpAuthentication) InmemoryDatabaseAdapterFactory(org.projectnessie.versioned.persist.inmem.InmemoryDatabaseAdapterFactory) NessieDbAdapterName(org.projectnessie.versioned.persist.tests.extension.NessieDbAdapterName) InmemoryTestConnectionProviderSource(org.projectnessie.versioned.persist.inmem.InmemoryTestConnectionProviderSource) NessieExternalDatabase(org.projectnessie.versioned.persist.tests.extension.NessieExternalDatabase) NessieApiV1(org.projectnessie.client.api.NessieApiV1) RequestFilter(org.projectnessie.client.http.RequestFilter) HEADER_ACCEPT(org.projectnessie.client.http.HttpUtils.HEADER_ACCEPT) URI(java.net.URI) Nullable(javax.annotation.Nullable) HttpClient(org.projectnessie.client.http.HttpClient) HttpAuthentication(org.projectnessie.client.http.HttpAuthentication) RequestFilter(org.projectnessie.client.http.RequestFilter) NessieApiV1(org.projectnessie.client.api.NessieApiV1)

Aggregations

NessieApiV1 (org.projectnessie.client.api.NessieApiV1)2 HttpClient (org.projectnessie.client.http.HttpClient)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 URI (java.net.URI)1 Nullable (javax.annotation.Nullable)1 Assumptions.assumeThat (org.assertj.core.api.Assumptions.assumeThat)1 HttpAuthentication (org.projectnessie.client.http.HttpAuthentication)1 HttpClientBuilder (org.projectnessie.client.http.HttpClientBuilder)1 HEADER_ACCEPT (org.projectnessie.client.http.HttpUtils.HEADER_ACCEPT)1 RequestFilter (org.projectnessie.client.http.RequestFilter)1 NessieHttpResponseFilter (org.projectnessie.client.rest.NessieHttpResponseFilter)1 InmemoryDatabaseAdapterFactory (org.projectnessie.versioned.persist.inmem.InmemoryDatabaseAdapterFactory)1 InmemoryTestConnectionProviderSource (org.projectnessie.versioned.persist.inmem.InmemoryTestConnectionProviderSource)1 NessieDbAdapterName (org.projectnessie.versioned.persist.tests.extension.NessieDbAdapterName)1 NessieExternalDatabase (org.projectnessie.versioned.persist.tests.extension.NessieExternalDatabase)1