HTTP メソッドに基づいてメッセージをフィルタリング/ルーティングする方法があるかどうか疑問に思っています。私がやろうとしているのは、OPTIONS メソッドで投稿された受信リクエストを処理しないことです。(これは、クロスオリジン リソース共有の処理用です)
3385 次
2 に答える
5
何かをしたい場合は、MEL(Mule Expression 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>
または、オプションでない場合にメッセージをドロップしたいだけの場合は、式フィルターを使用できます。
<expression-filter
expression="#[message.inboundProperties['http.method'] != 'OPTIONS']" />
ルーティングとフィルタリングの詳細については、次を参照してください。
http://www.mulesoft.org/documentation/display/current/Routing+Message+Processors
http://www.mulesoft.org/documentation/display/current/Using+Filters
于 2013-05-15T09:21:57.317 に答える