[英]How get ResourceUrl from Katharsis
When I try to rewrite Katharsis self link, I need add resource url as prefix. 当我尝试重写Katharsis自链接时,我需要添加资源URL作为前缀。
eg: "self": " http://localhost/table-name/A " Where I can get http://localhost/table-name . 例如:“ self”:“ http:// localhost / table-name / A ”在哪里可以获得http:// localhost / table-name 。
I found ResourceRegistry provider this method. 我找到了ResourceRegistry提供程序这种方法。 but I am not able to get ResourceRegistry instance。 Is any good way to get ResourceUrl ?
但是我无法获得ResourceRegistry实例。有什么好的方法来获取ResourceUrl吗?
ResourceRegistry
public String getResourceUrl(Class<?> clazz)
The localhost
part will be picked up from the host header. localhost
部分将从主机头中提取。 The prefix can be set in your application properties file. 可以在应用程序属性文件中设置前缀。 I think it's literally called
api.prefix
. 我认为它的字面是
api.prefix
。 If you want to override the local host part programmatically you can implement a bean of type 如果要以编程方式覆盖本地主机部分,则可以实现类型的Bean
ServiceUrlProvider
and declare it @Primary
ServiceUrlProvider
并将其声明为@Primary
Look at the spring boot example config 看一下Spring Boot示例配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.