Search code examples
javaapache-cameldsl

Default route for Apache Camel


I'm using Apache Camel. Using XML DSL, I mean something like

<rests id="rests" xmlns="http://camel.apache.org/schema/spring">
    <rest id="rest-custom">
        <get uri="my_method" method="">
            <description>...</description>
            <param name="..." ... />
            <route>
                <process ref="..." />
                <to uri="..." />
            </route>
        </get>

        <post uri="another_method" method="" >
            <description>...</description>
            <param name="..." .../>
            <route>
                <process ref="..." />
                <to uri="..." />
            </route>
        </post>
...

So if I want new route, I will just add new <get> or <post> and it works fine.

But now I want to add some DEFAULT method. I mean, something like <get uri="*"> and <post uri="*"> in the bottom of all configuration. So if my url doesn't match any from list - it goes to default one and I can handle it with custom processor (this is the behaviour I want).

For now I don't know, how to do it. Tried to handle 404 responses, but still no success. Looks like solution should be simple, but can't find it yet.


Solution

  • Finally found the solution.

    <get uri="/?matchOnUriPrefix=true&amp;bridgeEndpoint=true" method="">
        <description>Default GET method</description>
        <route>
           ...
        </route>
    </get>
    

    Parameters matchOnUriPrefix=true&bridgeEndpoint=true did the trick.