我使用Spring Boot配置了Camel REST,并启用了执行器/ camelroutes,如以下示例所示:https://github.com/apache/camel/blob/master/examples/camel-example-spring-boot/src/main/resources/application.properties
现在我能够获取我的路由说明...问题是它们显示为route1,route2等,并且没有提供描述,这使得很难区分哪个路由属于哪个REST端点,例如
{
"id": "route2",
"uptime": "3.172 seconds",
"uptimeMillis": 3172,
"properties": {
"parent": "49889154",
"rest": "true",
"description": null,
"id": "route2"
},
"status": "Started"
}
问题是如何为rest()路由提供自定义说明和ID?
我的路线很简单:
rest("/hello")
.description("/hello GET endpoint")
.consumes("application/json").produces("text/html")
.get("/").description("Hello World example").outType(String.class)
.to("direct:hello")
我尝试在.rest(“ / bla”)之后添加.description,但对执行器/骆驼路线没有影响
理想情况下,我想获得以下内容:
{
"id": "route1",
"description": "direct hello route returning simple string",
"uptime": "3.173 seconds",
"uptimeMillis": 3173,
"properties": {
"parent": "76af51d6",
"rest": "false",
"description": "direct hello route returning simple string",
"id": "route1"
},
"status": "Started"
},
答案 0 :(得分:0)
您需要将id
和description
设置为route
上下文,而不是rest
上下文。
例如以下定义:
rest("/hello")
.consumes("application/json").produces("text/html")
.get("/").outType(String.class)
.route().id("sayHi").description("This endpoint says Hi")
.to("direct:hello");
from("direct:hello")
.routeId("hello")
.setBody(constant("Hi"));
生成此执行器输出:
[
{
"id": "hello",
"uptime": "13.158 seconds",
"uptimeMillis": 13158,
"status": "Started"
},
{
"id": "sayHi",
"description": "This endpoint says Hi",
"uptime": "13.145 seconds",
"uptimeMillis": 13145,
"status": "Started"
}
]