我想知道是否有一种基于HTTP方法过滤/路由消息的方法.我想要做的是不处理使用OPTIONS方法发布的传入请求.(这是用于跨源资源共享处理)
您可以使用MEL(Mule Exression Language - http://www.mulesoft.org/documentation/display/current/Mule+Expression+Language+MEL)查询http.method参数和选择路由器(如果您想要执行某些操作)使用OPTIONS请求,例如发回允许的方法,如下所示:
<choice doc:name="Choice">
<when expression="#[message.inboundProperties['http.method'] == 'OPTIONS']">
<http:response-builder status="200"
doc:name="HTTP Response Builder(200 - OPTIONS)">
<http:header name="Allow" value="GET" />
<http:header name="Content-Type" value="#[null]" />
<set-payload value="#[null]" />
</http:response-builder>
</when>
<otherwise>
<!-- Do something else -->
</oherwise>
</choice>
Run Code Online (Sandbox Code Playgroud)
或者,如果您只想删除消息,则可以使用表达式过滤器:
<expression-filter
expression="#[message.inboundProperties['http.method'] != 'OPTIONS']" />
Run Code Online (Sandbox Code Playgroud)
有关路由和过滤的更多信息:
http://www.mulesoft.org/documentation/display/current/Routing+Message+Processors
http://www.mulesoft.org/documentation/display/current/Using+Filters
| 归档时间: |
|
| 查看次数: |
3225 次 |
| 最近记录: |