use of com.networknt.client.http.Http2ServiceRequest in project light-4j by networknt.
the class RestClientTemplate method execute.
protected <T> T execute(ServiceDef serviceDef, String path, Class<T> responseType, Map<String, ?> headerMap, HttpString method, String requestBody) throws RestClientException {
try {
Http2ServiceRequest http2ServiceRequest = new Http2ServiceRequest(serviceDef, path, method);
if (statusCodesValid.isPresent())
http2ServiceRequest.setStatusCodesValid(statusCodesValid.get());
http2ServiceRequest.setRequestHeaders(headerMap);
if (requestBody != null)
http2ServiceRequest.setRequestBody(requestBody);
return http2ServiceRequest.callForTypedObject(responseType).get();
} catch (Exception e) {
String errorStr = "execute the restful API call error:";
logger.error(errorStr + e);
throw new RestClientException(errorStr, e);
}
}
use of com.networknt.client.http.Http2ServiceRequest in project light-4j by networknt.
the class RestClientTemplate method execute.
protected <T> T execute(String url, String path, Class<T> responseType, Map<String, ?> headerMap, HttpString method, String requestBody) throws RestClientException {
try {
Http2ServiceRequest http2ServiceRequest = new Http2ServiceRequest(new URI(url), path, method);
if (statusCodesValid.isPresent())
http2ServiceRequest.setStatusCodesValid(statusCodesValid.get());
http2ServiceRequest.setRequestHeaders(headerMap);
if (requestBody != null)
http2ServiceRequest.setRequestBody(requestBody);
return http2ServiceRequest.callForTypedObject(responseType).get();
} catch (Exception e) {
String errorStr = "execute the restful API call error:";
logger.error(errorStr + e);
throw new RestClientException(errorStr, e);
}
}
Aggregations