javamonkey79
javamonkey79

Reputation: 17775

Restlet Default Route?

I'm trying to setup a couple routes with the restlet framework, but I can't seem to figure out how to setup a "default route".

I tried this:

@Override
public Restlet createInboundRoot() {
    Router router = new Router( getContext() );

    router.attach( "http://localhost:8111/", TestActionResource.class );
    router.attach( "http://localhost:8111/echo", EchoResource.class );

    router.setDefaultRoute( router.getRoutes().get( 0 ) );

    return router;
}

But when I try something like:

http://localhost:8111/something

I get a "not found" error message.

Is there an easy way to default pages that are not found from the router?

Thanks.

Upvotes: 2

Views: 1017

Answers (1)

javamonkey79
javamonkey79

Reputation: 17775

I almost had it, this is it:

@Override
public Restlet createInboundRoot() {
    Router router = new Router( getContext() );

    router.attachDefault( TestActionResource.class );
    router.attach( "http://localhost:8111/echo", EchoResource.class );

    return router;
}

Upvotes: 3

Related Questions