Skip to content

How to actually use an okhttp client #410

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

Closed
tropikoder opened this issue Jul 13, 2022 · 2 comments
Closed

How to actually use an okhttp client #410

tropikoder opened this issue Jul 13, 2022 · 2 comments

Comments

@tropikoder
Copy link

what i need is to build a com.meilisearch.sdk.Client that uses OkHttp and jackson whenever it makes requests

I read the example on OkHttp in the documentation (and in the test source), but don't understand where to use the resulting serviceTemplate.

Thank you

Config config = new Config("http://localhost:7700", "masterKey");
HttpAsyncClient client = HttpAsyncClients.createDefault();
ApacheHttpClient client = new ApacheHttpClient(config, client);
private final JsonHandler jsonHandler = new JacksonJsonHandler(new ObjectMapper());
private final RequestFactory requestFactory = new BasicRequestFactory(jsonHandler);
private final GenericServiceTemplate serviceTemplate = new GenericServiceTemplate(client, jsonHandler, requestFactory);

private final ServiceTemplate serviceTemplate;
serviceTemplate.getProcessor().encode("your_data");
```


@alallema
Copy link
Contributor

Hi @tropikoder,
Very sorry for the delay of answer. This part of the code was added a long time ago by a contributor to refactor the SDK; it was designed to create customizable handlers for each class such as :

    private final IndexHandler indexHandler = new IndexHandler(serviceTemplate, serviceTemplate.getRequestFactory());

But the final code was never merged so this part of the code is not fully functional. A big refactoring of the SDK is planned with only the use of the OkHttp client and will be available in a few weeks if all goes well.
I'm not sure if my answer will help you a lot...

@alallema
Copy link
Contributor

alallema commented Nov 9, 2022

Close due to merge of #425

@alallema alallema closed this as completed Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants