我正在使用Apache Camel。使用XML DSL,我的意思是类似
<rests id="rests" xmlns="http://camel.apache.org/schema/spring">
<rest id="rest-custom">
<get uri="my_method" method="">
<description>...</description>
<param name="..." ... />
<route>
<process ref="..." />
<to uri="..." />
</route>
</get>
<post uri="another_method" method="" >
<description>...</description>
<param name="..." .../>
<route>
<process ref="..." />
<to uri="..." />
</route>
</post>
...
因此,如果我想要新的路线,我只需添加新的<get>
或<post>
,它就可以正常工作。
但是现在我想添加一些DEFAULT方法。我的意思是,类似所有配置底部的<get uri="*">
和<post uri="*">
。因此,如果我的网址与列表中的任何网址都不匹配-它将变为默认网址,并且我可以使用自定义处理器进行处理(这是我想要的行为)。
目前我不知道该怎么做。试图处理404响应,但仍然没有成功。看起来解决方案应该很简单,但是还找不到。
具有相同功能的多个URL。
如果是这种情况,并且您的客户不希望或无法切换到单个URL,则在传入请求到达您的Camel应用程序之前,您仍可以对传入请求使用URL重写
。如果您想“捕获”所有未知URL
(错误),我猜您应该使用标准骆驼错误处理(请参阅Error Handler和Exception clause),因为这些REST DSL块在内部转换为标准的骆驼路线。<get uri="/?matchOnUriPrefix=true&bridgeEndpoint=true" method="">
<description>Default GET method</description>
<route>
...
</route>
</get>
参数matchOnUriPrefix = true&bridgeEndpoint = true达到了目的。