Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Need to be able to implement this without needing to know what the resolved server URL is.
DESIRED FUNCTIONALITY--
.defineRule()
.when(Path.matches("/login").and(Scheme.matches("http")))
.perform(Redirect.temporary("https://server.com/login"));
OR--
.defineRule()
.when(Path.matches("/login").and(Scheme.matches("http")))
.perform(new HttpOperation() {
@Override
public void performHttp(HttpServletRewrite event, EvaluationContext context)
{
String url = event.getRequest().getRequestURL().toString().replaceFirst("http", "https");
Redirect.temporary(url).perform(event, context);
}
})
SHORTHAND OPTIONS--
.defineRule()
.when(Path.matches("/login").and(Scheme.matches("http")))
.perform(Redirect.toScheme("https"))
OR--
.defineRule()
.when(URL.captureIn("url").and(Path.matches("/login")).and(Scheme.matches("http")))
.perform(Redirect.permanent("{url}").toScheme("https"))
@lincolnthree
Copy link
Author

lincolnthree commented May 13, 2012

How can this be improved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment