Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Idiomatic "create an alias" handler?

Hi Folks,

(Note - I'm not after "honor/recognize a unix/windows symlink or Alias")

I've created a "MovedContextHandler" in the test-logic of an OSS project - 
https://github.com/paul-hammant/ngWebDriver/blob/master/src/test/java/com/paulhammant/ngwebdriver/AngularAndWebDriverTest.java#L58

It is because I've source a test-web-app from another OSS project, and that one has one of two alternates for a certain 'angular' directory - https://github.com/angular/protractor/tree/master/testapp/lib and in their test suite (using 'express' not Jetty) they have one of the two alternates mapped to the shorter 'angular' directory.

Anyway, I'm doing:

MovedContextHandler effective_symlink = new MovedContextHandler();
effective_symlink.setNewContextURL("/lib/angular_v1.2.9");
effective_symlink.setContextPath("/lib/angular");
effective_symlink.setPermanent(false);
effective_symlink.setDiscardPathInfo(false);
effective_symlink.setDiscardQuery(false);
handlers.setHandlers(new Handler[] { effective_symlink, resource_handler, new DefaultHandler() }); 

I was hoping for a:

handlers.setHandlers(new Handler[] { tempForwardFrom("/lib/angular").to("lib/angular_v1.2.9"), resource_handler, new DefaultHandler() }); 

Or at least an elegant one-liner.

Regards,

- Paul

Back to the top