【发布时间】:2018-01-04 01:04:31
【问题描述】:
如何在没有 concat/hardcode 字符串的情况下获取特定的 Spring Boot 控制器端点完整 url?我的情况是需要向外部 url 发送请求并从中获取异步通知,因此我需要将通知端点完整 url 传递给它。这是示例代码:
@RestController
@RequestMapping("/api/v1")
public class MyController {
@PostMapping("/sendRequest")
public void sendRequest() {
...
// 1. get /notifyStatus endpoint full url to be send to external service
String myNotificationFullUrl = xxx ?
// 2. call external service
}
@GetMapping("/notifyStatus")
public void notifyStatus() {
...
}
}
【问题讨论】:
标签: spring url spring-boot controller endpoint