Jak*_*iuk 9 rest java-ee wildfly-8
有没有办法(例如从WildFly管理控制台)列出在WildFly中部署的所有REST端点?或者在服务器启动时将它们列在日志中?
RegistryStatsResource使用RESTEasy(随WildFly一起提供),您可以将以下内容添加到web.xml:
<context-param>
<param-name>resteasy.resources</param-name>
<param-value>org.jboss.resteasy.plugins.stats.RegistryStatsResource</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
然后请求以下URL:
http://[hostname]:[port]/[context]/[api-path]/resteasy/registry
Run Code Online (Sandbox Code Playgroud)
这样的端点可以生成XML和JSON内容.只需Accept使用所需的媒体类型将标头添加到请求中:
application/xmlapplication/json如果您对创建自己的实现的源代码感兴趣,请查看RegistryStatsResourceGitHub上的类.
源代码中最相关的部分如下所示(它特定于RESTEasy):
ResourceMethodRegistry registry = (ResourceMethodRegistry)
ResteasyProviderFactory.getContextData(Registry.class);
for (String key : registry.getBounded().keySet()){
List<ResourceInvoker> invokers = registry.getBounded().get(key);
for (ResourceInvoker invoker : invokers) {
if (invoker instanceof ResourceMethodInvoker) {
ResourceMethodInvoker rm = (ResourceMethodInvoker) invoker;
// Extract metadata from the ResourceMethodInvoker
}
}
Run Code Online (Sandbox Code Playgroud)
根据您的要求,您可以使用Swagger来记录您的API.它附带了一组用于描述REST端点的注释.
然后使用Swagger UI为您的API提供实时文档.
注意:截至2017年2月,RegistryStatsResource该类似乎完全没有记录.我在挖掘RESTEasy源代码以进行调试时偶尔会发现它.此外,我发现这个JBoss EAP问题跟踪该类缺乏文档.
| 归档时间: |
|
| 查看次数: |
2293 次 |
| 最近记录: |