Skip to content

Commit

Permalink
Redirect improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Feb 13, 2020
1 parent d7fcc26 commit 7fc1a12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> ServerResponse<T> redirect(String location, boolean includeParameters)
{

exchange.getResponseHeaders().put(Headers.LOCATION, RedirectBuilder.redirect(exchange, location, includeParameters));
exchange.setStatusCode(302);
exchange.endExchange();

return new ServerResponse<>();
}

/**
Expand Down

0 comments on commit 7fc1a12

Please sign in to comment.