Basically it was added for backward compatibility with JBoss Web.

Stuart

On Fri, 10 Jul 2020 at 06:48, Brad Wood <bdw429s@gmail.com> wrote:
While I'm asking about rewrites, I should mention I have come across the io.undertow.servlet.compat.rewrite package, however
  • It's not mentioned anywhere in the docs
  • The code itself has no comments of any kind explaining it
  • There's no handlerbuilder so it doesn't appear the RewriteHandler can be used with Undertow's predicate language
I am intrigued by it since it appears to be specifically written to fire in the servlet's handler chain and it appears to be a rather robust implementation, I just can't find any docs on how to use it!  

What is the backstory with Undertow core rewrite handler and servlet rewrite handler?

Thanks!

~Brad

Developer Advocate
Ortus Solutions, Corp 

ColdBox Platform: http://www.coldbox.org 



On Thu, Jul 9, 2020 at 11:42 AM Brad Wood <bdw429s@gmail.com> wrote:
So, in my bid to put the predicate language through the paces, I've been testing out all the rewrite rules I've ever used with mod_rewrite or Tuckey Rewrite to see if Undertow's handlers are up to the task.  

I've run into an issue again with probably the most common rewrite rule of any CFML app using an MVC framework, which is a rule that creates so-called "SES" URLs and force all requests through a front controller design pattern.  

Basically

site.com/home/about

gets rewritten to

site.com/index.cfm/home/about

Here you can see how this rule is typically accomplished in Apache httpd, Nginx, IIS, and Tuckey:

 
The hang up is that any incoming path that maps to an actual file skips the rewrite rule.  That way /images/logo.jpg doesn't get rewritten. 

So here was my first stab at it with Undertow's predicate language-- it seemed simple enough:

not file and not directory -> rewrite('/index.cfm/%{RELATIVE_PATH}')

But our old friend the servlet of course is nowhere to be found since my "file" and "directory" predicates were executing in the root handler chain so there is no concept of a servlet's context root with which to resolve file system paths. 

So basically, I understand exactly why this doesn't work, but I feel that we need to find a way to make this work.  This is a feature that pretty much every rewrite engine I've ever used has-- the ability to test the file system to see if a file or directory exists.  Can we discuss the following options?
  • Find a way for the root handler chain to access the deployment's resource manager 
  • Find a way for the rewrite handler to correctly affect not only the exchange but also (optionally) the HttpServletRequest so it's possible to rewrite the URL inside of the servlet's handler chain. I know for certain this is possible because the Tuckey Rewrite engine is implemented as a servlet filter.
I would prefer the first option since I do like having the predicates in the root handler chain so it can run as early as possible.

Thanks!

~Brad

Developer Advocate
Ortus Solutions, Corp 

ColdBox Platform: http://www.coldbox.org 

_______________________________________________
undertow-dev mailing list
undertow-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/undertow-dev