【发布时间】:2019-08-14 13:31:03
【问题描述】:
例如,如果我有以下控制器:
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.*;
@Controller("/test")
public class TestController {
@Get()
@Produces(MediaType.TEXT_PLAIN)
public String index() {
// How should this be implemented?
return "???";
}
}
我在我的服务器上运行它,然后我希望索引方法返回http://my-server:8080。
【问题讨论】:
-
您想要返回运行应用程序的主机的主机名和端口,还是想要返回您的 API 如何访问的基本 URL(例如,在代理之后)?
-
@saw303 后者会更好,但现在前者已经足够了。
标签: java web-services micronaut