174.11. 自定义 HttpBinding
默认情况下,Camel 使用 org.apache.camel.component.http.DefaultHttpBinding
来处理如何写入响应。如果您愿意,您可以通过实施自己的 HttpBinding
类或扩展 DefaultHttpBinding
并覆盖适当的方法来自定义此行为。
以下示例演示了如何自定义 DefaultHttpBinding
以更改返回异常:
然后,我们创建一个绑定实例,并在 Spring registry 中注册它,如下所示:
<bean id="mybinding"class="com.mycompany.MyHttpBinding"/>
<bean id="mybinding"class="com.mycompany.MyHttpBinding"/>
然后,在定义路由时我们可以引用此绑定:
<route> <from uri="jetty:http://0.0.0.0:8080/myapp/myservice?httpBindingRef=mybinding"/> <to uri="bean:doSomething"/> </route>
<route>
<from uri="jetty:http://0.0.0.0:8080/myapp/myservice?httpBindingRef=mybinding"/>
<to uri="bean:doSomething"/>
</route>