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
Watch a video
See this example built and run in Mule Studio
This example adds a new filter to the existing 'core-concepts' project created in the Adding Business Logic to a Flow example.
Make sure the "Message Flow" view is open in Mule Studio:
Select the "Filters" panel and drag the "Wildcard" filter, dropping it on top of the arrow leaving the HTTP inbound end-point:
Double click the Wildcard filter you just added and enter "/Mule-" in the pattern field and "Mule- Filter" in the name field. Be sure to check the "Case Sensitive" check box:
Click the Documentation tab and fill in the description field:
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 not passed on.