Filtering Invalid Requests
Sometimes you need to prevent your Mule application from processing requests known to be invalid or that have invalid data. This example shows you how to use filters to reject such invalid requests.
How to use filters to control which requests are processed
How to configure a particular kind of filter, the "Wildcard" filter
See this example built and run in Mule Studio
This example adds a new filter to the existing 'core-concepts' project created in the Understanding the Mule Message example.
\1. Make sure the "Message Flow" view is open in Mule Studio:
\2. Select the "Filters" panel and drag the "Wildcard" filter, dropping it on top of the arrow leaving the HTTP inbound end-point:
\3. Double click the Wildcard filter you just added and enter "/Mule-*" in the pattern field. Be sure to check the "Case Sensitive" check box:
\4. Click the Documentation tab and fill in the name and description fields:
To run the example, right click in the project tree, select Run As.. -→ Mule Application. You’ll see logging information in the console window as the application starts.
In a browser window go to http://localhost:8082/Fred and you should see the following on screen:
The application quite rudely refused to greet Fred. Now go to go to http://localhost:8082/Mule-Fred instead. You should see the following:
Notice that the application now has a Mule bias.
You added a filter to a flow. The filter conditionally controls which data is allowed to pass through to the flow
You modified an HTTP inbound end-point to reject requests that do not start with "Mule-". Rejected requests are just parroted back on the HTTP response and are not passed on to the HelloComponent.