Created
May 13, 2012 03:10
-
-
Save lincolnthree/2673529 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can this be improved?