Prashant Prabhakar Singh
Prashant Prabhakar Singh

Reputation: 1190

How to add regex to Camel routes?

I am trying to add regex to camel routes. But I am really not getting any hint. I am using this route to server a static resource (index.html):

from("pjetty:http://0.0.0.0:{{http.port}}/user/?matchOnUriPrefix=true")    
    .process( new StaticProcessor( "/dist/", "index.html", "dist"))
    .routeId( "static");

I am able to access the index.html via following urls:

http://loccalhost:8080/user/index.html
http://localhost:8080/user/

Now I want any url starting with http://loccalhost:8080/user to render index page. Like:

http://loccalhost:8080/user/abc/index.html
http://localhost:8080/user/test/
http://localhost:8080/user/anyting 

How can I achieve that?

Upvotes: 0

Views: 195

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55525

Camel is not a web server btw, so whatever you want to render or return as web response, is whatever you do in that StaticProcessor you have coded yourself.

You can get the actual URL that was requested from the Camel Message header, and from that information, you can decide what to render.

Upvotes: 3

Related Questions