|
7 | 7 | import io.swagger.annotations.Api; |
8 | 8 | import io.swagger.annotations.ApiOperation; |
9 | 9 | import io.swagger.annotations.ApiParam; |
| 10 | +import org.apache.commons.io.IOUtils; |
10 | 11 | import org.apache.dubbo.config.annotation.Reference; |
11 | 12 | import org.apache.http.HttpResponse; |
12 | 13 | import org.apache.http.client.HttpClient; |
|
22 | 23 | import org.springframework.http.ResponseEntity; |
23 | 24 | import org.springframework.web.bind.annotation.GetMapping; |
24 | 25 | import org.springframework.web.bind.annotation.PathVariable; |
| 26 | +import org.springframework.web.bind.annotation.RequestMapping; |
25 | 27 | import org.springframework.web.bind.annotation.RestController; |
26 | 28 | import org.springframework.web.client.RestTemplate; |
27 | 29 |
|
28 | 30 | import javax.annotation.PostConstruct; |
29 | 31 | import javax.servlet.http.HttpServletRequest; |
| 32 | +import java.nio.charset.Charset; |
30 | 33 | import java.util.Enumeration; |
31 | 34 | import java.util.List; |
32 | 35 | import java.util.concurrent.ExecutionException; |
33 | 36 |
|
34 | 37 | @Api(value = "/", tags = {"入口应用"}) |
35 | 38 | @RestController |
36 | 39 | class AController { |
| 40 | + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(AController.class); |
37 | 41 |
|
38 | 42 | @Autowired |
39 | 43 | @Qualifier("loadBalancedRestTemplate") |
@@ -83,8 +87,14 @@ private void init() { |
83 | 87 | } |
84 | 88 |
|
85 | 89 | @ApiOperation(value = "HTTP 全链路灰度入口", tags = {"入口应用"}) |
86 | | - @GetMapping("/a") |
| 90 | + @RequestMapping("/a") |
87 | 91 | public String a(HttpServletRequest request) throws ExecutionException, InterruptedException { |
| 92 | + try { |
| 93 | + String body = IOUtils.toString(request.getInputStream(), Charset.defaultCharset()); |
| 94 | + log.info("body is {}", body); |
| 95 | + } catch (Throwable e) { |
| 96 | + log.warn("get body error", e); |
| 97 | + } |
88 | 98 | StringBuilder headerSb = new StringBuilder(); |
89 | 99 | //枚举创建完后无法更改 |
90 | 100 | Enumeration<String> enumeration = request.getHeaderNames(); |
|
0 commit comments