use of com.predic8.membrane.core.transport.http.HttpClient in project service-proxy by membrane.
the class Test method main.
public static void main(String[] args) throws Exception {
URIFactory uriFactory = new URIFactory();
uriFactory.setAllowIllegalCharacters(true);
Response res = new HttpClient().call(new Request.Builder().get(uriFactory, "http://localhost:2000/a.{/").buildExchange()).getResponse();
System.out.println(res.getStatusCode());
System.out.println(res.getStartLine());
}
use of com.predic8.membrane.core.transport.http.HttpClient in project service-proxy by membrane.
the class SwaggerProxy method init.
@Override
public void init() throws Exception {
super.init();
// download swaggerUrl
HttpClient hc = new HttpClient(router.getHttpClientConfig());
Exchange ex = hc.call(new Request.Builder().get(swaggerUrl).buildExchange());
if (ex.getResponse().getStatusCode() != 200) {
log.error("Couldn't fetch Swagger URL!");
throw new Exception("Couldn't fetch Swagger URL!");
}
// parse swaggerUrl
swagger = new SwaggerParser().parse(ex.getResponse().getBodyAsStringDecoded());
// pass swagger specification to Swagger Key
((SwaggerProxyKey) key).setSwagger(swagger);
((SwaggerProxyKey) key).setAllowUI(allowUI);
// add interceptor to position 0.
SwaggerRewriterInterceptor sri = new SwaggerRewriterInterceptor(swagger, swaggerUrl);
interceptors.add(0, sri);
}
Aggregations