[undertow-dev] Rewrite with parameters in undertow

Stuart Douglas sdouglas at redhat.com
Sat Jun 28 00:36:39 EDT 2014



Dariusz Borowski wrote:

The rules are applied one after the other, and it does not stop if one 
is matched, so both path-template['/Gender.action'] elements match, and 
the last one is the one that takes effect.

regex['^/Women/$'] -> set[attribute='%{q,gender}', value='women']
regex['^/Women/$'] -> rewrite['/Gender.action']

regex['^/Men/$'] -> set[attribute='%{q,gender}',  value='men']
regex['^/Men/$'] -> rewrite['/Gender.action']

Really you don't even need regex as it is just a literal match, and can 
just use path['/Men/'] which is more efficient.

I have never been 100% happy with this syntax, and I do have plans to 
expand it in future, so you will be able to do something like:

path[/Men] -> {
   set['%{q,gender}', 'women']
   rewrite['/Gender.action']
}

But I am still thinking about how the final syntax will turn out.

Stuart

> Hi guys,
>
> I'm struggling getting this working. I need to implement rewrite rules
> in my application. It's somehow working. What I do have, is:
>
> undertow-handlers.conf under /WEB-INF/
>
>
> trying to do simple rule:
>
>
> regex['^/Women/$'] -> rewrite['/Gender.action']
> path-template['/Gender.action'] -> set[attribute='%{q,gender}',
> value='women']
>
>
>
> In both cases it should hit my "Gender.action", but with a different
> parameter!
>
> It always applies to the last set path-template and the gender is
> always: "men"....
>
> How can I pass different parameters to the same Action?
>
> Thanks!
>
>
>
>
>
> --
>
> Dariusz Borowski
>
> STYLIGHT
>
> +49 (0) 89 - 1222 895 - 0
> +49 (0) 89 - 1222 895 - 48
> dariusz.borowski at stylight.com <mailto:dariusz.borowski at stylight.com>
> http://www.stylight.com/ <http://www.stylight.com/>
>
>
> Join us on Facebook: http://www.facebook.com/stylight
> Follow us on Twitter: http://www.twitter.com/stylight
> Follow us on Instagram: http://instagram.com/stylight
>
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev


More information about the undertow-dev mailing list