DELETE方法支持jsonBody
This commit is contained in:
parent
6f0f123b09
commit
fb48afc6ae
@ -79,6 +79,8 @@ public class RestRemoteHandler implements InvocationHandler {
|
|||||||
requestMethod = RequestMethod.DELETE;
|
requestMethod = RequestMethod.DELETE;
|
||||||
RemoteDeleteMethod deleteMethod = method.getAnnotation(RemoteDeleteMethod.class);
|
RemoteDeleteMethod deleteMethod = method.getAnnotation(RemoteDeleteMethod.class);
|
||||||
uri = deleteMethod.value();
|
uri = deleteMethod.value();
|
||||||
|
// 判断json
|
||||||
|
requestBody = getRequestBody(method.getParameters(), args);
|
||||||
} else if (method.isAnnotationPresent(RemotePostMethod.class)) {
|
} else if (method.isAnnotationPresent(RemotePostMethod.class)) {
|
||||||
// POST请求
|
// POST请求
|
||||||
requestMethod = RequestMethod.POST;
|
requestMethod = RequestMethod.POST;
|
||||||
|
@ -70,7 +70,11 @@ public class RestRemoteRequest {
|
|||||||
if (RequestMethod.GET.equals(requestMethod)) {
|
if (RequestMethod.GET.equals(requestMethod)) {
|
||||||
result = get(remoteUri, headers);
|
result = get(remoteUri, headers);
|
||||||
} else if (RequestMethod.DELETE.equals(requestMethod)) {
|
} else if (RequestMethod.DELETE.equals(requestMethod)) {
|
||||||
result = delete(remoteUri, headers);
|
if (jsonBody != null) {
|
||||||
|
result = delete(remoteUri, headers, jsonBody);
|
||||||
|
} else {
|
||||||
|
result = delete(remoteUri, headers);
|
||||||
|
}
|
||||||
} else if (RequestMethod.POST.equals(requestMethod)) {
|
} else if (RequestMethod.POST.equals(requestMethod)) {
|
||||||
// form表单优先
|
// form表单优先
|
||||||
if (!fileVariableParams.isEmpty() || !fileInputVariableParams.isEmpty() || !formVariableParams.isEmpty()) {
|
if (!fileVariableParams.isEmpty() || !fileInputVariableParams.isEmpty() || !formVariableParams.isEmpty()) {
|
||||||
@ -121,6 +125,23 @@ public class RestRemoteRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE请求
|
||||||
|
*
|
||||||
|
* @param remoteUri
|
||||||
|
* @param headers
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String delete(String remoteUri, Map<String, String> headers, Object jsonBody) {
|
||||||
|
try {
|
||||||
|
HttpEntity<String> httpEntity = getHttpEntity(headers, null, null, null, jsonBody);
|
||||||
|
ResponseEntity<String> responseEntity = getRestTemplate(remoteUri).exchange(remoteUri, HttpMethod.DELETE, httpEntity, String.class);
|
||||||
|
return getStringResponse(responseEntity);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return getErrorResponse(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST请求
|
* POST请求
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user