Commit e5df8643 authored by 赵啸非's avatar 赵啸非

修改配置文件

parent 913a224a
...@@ -34,11 +34,20 @@ public class ProxyController { ...@@ -34,11 +34,20 @@ public class ProxyController {
@RequestHeader Map<String, String> headers // 透传 Headers @RequestHeader Map<String, String> headers // 透传 Headers
) { ) {
String path = params.getOrDefault("path", ""); log.info("proxyPost params: {}, body: {}, headers: {}", params, body, headers);
ApiResp<String> rsp = new ApiResp<>(); ApiResp<String> rsp = new ApiResp<>();
if (!ObjectUtils.isEmpty(path)) { String path = params.getOrDefault("path", "");
String targetUrl = "http://127.0.0.1:11072/basic_api/" + path; if (ObjectUtils.isEmpty(path)) {
rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
rsp.setMsg("path is empty!");
return Mono.just(ResponseEntity.ok().body(JSON.toJSONString(rsp)));
}
String method = params.getOrDefault("method", "post");
String targetUrl = "http://127.0.0.1:11072/basic_api/" + path;
if ("post".equalsIgnoreCase(method)) {
return webClient.post() return webClient.post()
.uri(uriBuilder -> { .uri(uriBuilder -> {
uriBuilder.path(targetUrl); uriBuilder.path(targetUrl);
...@@ -51,13 +60,11 @@ public class ProxyController { ...@@ -51,13 +60,11 @@ public class ProxyController {
.bodyValue(body != null ? body : "") // 透传 Body .bodyValue(body != null ? body : "") // 透传 Body
.retrieve() .retrieve()
.toEntity(String.class); .toEntity(String.class);
} else { } else if ("get".equalsIgnoreCase(method)) {
rsp.setCode(ApiRespCodeEnum.FAILED.getValue()); } else {
rsp.setMsg("path is empty!"); //不支持
return Mono.just(ResponseEntity.ok().body(JSON.toJSONString(rsp)));
} }
return Mono.just(ResponseEntity.ok().body(JSON.toJSONString(rsp)));
} }
} }
...@@ -63,7 +63,7 @@ Content-Type: application/json ...@@ -63,7 +63,7 @@ Content-Type: application/json
} }
###透传代理接口 ###透传代理接口
POST {{baseUrl}}/proxy/post?path= POST {{baseUrl}}/proxy/post?path=/ent/life/cycle/interlist&method=post
Content-Type: application/json Content-Type: application/json
{} {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment