diff --git a/CHANGELOG.md b/CHANGELOG.md index d107593..17bdb7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Proteus Changelog. ## Unreleased ### No issue +**Added redirect mechanism on ServerRequest.** + + +[d7fcc26ab5ff4a7](https://github.com/noboomu/proteus/commit/d7fcc26ab5ff4a7) Joshua Bauer *2020-02-13 22:06:02* + **Cleanup pom.** diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/ServerRequest.java b/proteus-core/src/main/java/io/sinistral/proteus/server/ServerRequest.java index a7c3179..4114ea7 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/ServerRequest.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/ServerRequest.java @@ -181,13 +181,20 @@ public void startAsync(final Executor executor, final Runnable runnable) exchange.dispatch(executor, runnable); } - public void redirect(String location, boolean includeParameters) + /** + * Abort current request and respond with redirect. Returns empty @ServerResponse for convenience. + * @param location + * @param includeParameters + * @return serverResponse + */ + public ServerResponse redirect(String location, boolean includeParameters) { exchange.getResponseHeaders().put(Headers.LOCATION, RedirectBuilder.redirect(exchange, location, includeParameters)); exchange.setStatusCode(302); exchange.endExchange(); + return new ServerResponse<>(); } /**