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

Generic service to access external api for all the plugins. #154

Open
marcelanita opened this issue Oct 26, 2021 · 2 comments
Open

Generic service to access external api for all the plugins. #154

marcelanita opened this issue Oct 26, 2021 · 2 comments

Comments

@marcelanita
Copy link

Any plugin should have access to a common generic service to be able to connect to an external api. This should be done with org.jboss.resteasy.client.jaxrs.ResteasyClient .

@marcelanita
Copy link
Author

marcelanita commented Oct 27, 2021

public T doGet( Class clazz, String url, String path) {
    ResteasyClient client = new ResteasyClientBuilderImpl()
            .connectionPoolSize(30)
            .connectTimeout(20, TimeUnit.SECONDS)
            .build();
    ResteasyWebTarget target = client.target(url).path(path);
    Response response = target.request().get();
    String value = response.readEntity(String.class);
    response.close();
    T data = new Gson().fromJson(value, clazz);
    return data;
}

@marcelanita
Copy link
Author

see the class org.gluu.casa.plugins.consentmanagementportal.client.BaseExternalApiClient from the branch feature/Open-Banking-Consent-Portal , this class should be placed in a common module

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

1 participant