173.11. Customizing HttpBinding

默认情况下,Camel 使用 org.apache.camel.component.http.DefaultHttpBinding 处理编写响应的方式。如果您愿意,您可以通过实现自己的 HttpBinding 类或扩展 DefaultHttpBinding 并覆盖适当的方法来自定义此行为。

以下示例演示了如何自定义 DefaultHttpBinding,以更改返回异常的方式:

然后,我们可以创建一个绑定实例,并将其注册到 Spring registry 中,如下所示:

<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>