Skip to content

Instantly share code, notes, and snippets.

@lincolnthree
Created May 13, 2012 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lincolnthree/2673529 to your computer and use it in GitHub Desktop.
Save lincolnthree/2673529 to your computer and use it in GitHub Desktop.
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

How can this be improved?

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