public class Redirector extends HttpMiddleware implements HttpConstants
// This middleware redirects "/" path to "index.html"
route.use(new Redirector("/", "index.html", 307));
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
formattedPath
Path to redirect (formatted and checked).
|
protected java.lang.String |
htmlTemplate
Template of the HTML response.
|
protected java.lang.String |
location
URL of the redirection.
|
protected java.lang.String |
path
Path to redirect (null = redirects all requests).
|
protected int |
status
307 = Temporary Redirect.
|
ACCEPT, ACCEPT_ENCODING, AUTHORIZATION, CACHE_CONTROL, CHUNKED, CLOSE, CONNECT, CONNECTION, CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE, CONTENT_TYPE_HTML, CONTENT_TYPE_JSON, COOKIE, DEFLATE, DELETE, ETAG, GET, GZIP, HEAD, IF_NONE_MATCH, KEEP_ALIVE, LOCATION, META_CONTENT_TYPE, META_HEADERS, META_LOCALE, META_LOCATION, META_SESSION, META_STATUS, META_TEMPLATE, NO_CACHE, OPTIONS, PATCH, POST, PROPERTY_COOKIES, PROPERTY_SESSION_ID, PROPERTY_USER, PUT, SET_COOKIE, TRACE, TRANSFER_ENCODING, WWW_AUTHENTICATE, X_FORWARDED_FOR| Constructor and Description |
|---|
Redirector() |
Redirector(java.lang.String path)
Redirects browser from "path" to "index.html".
|
Redirector(java.lang.String path,
java.lang.String location)
Redirects browser from "path" to "location" URI.
|
Redirector(java.lang.String path,
java.lang.String location,
int status)
Redirects browser from "path" to "location" URI.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getHtmlTemplate() |
java.lang.String |
getLocation() |
java.lang.String |
getPath() |
int |
getStatus() |
RequestProcessor |
install(RequestProcessor next,
io.datatree.Tree config) |
void |
setHtmlTemplate(java.lang.String htmlTemplate) |
void |
setLocation(java.lang.String location) |
void |
setPath(java.lang.String path) |
void |
setStatus(int status) |
protected int status
protected java.lang.String path
protected java.lang.String formattedPath
protected java.lang.String location
protected java.lang.String htmlTemplate
public Redirector()
public Redirector(java.lang.String path)
path - redirect FROM (eg. "/deleted-page.html")public Redirector(java.lang.String path,
java.lang.String location)
path - redirect FROM (eg. "/deleted-page.html")location - redirect TO (eg. "new-page.html")public Redirector(java.lang.String path,
java.lang.String location,
int status)
path - redirect FROM (eg. "/deleted-page.html")location - redirect TO (eg. "new-page.html")status - status code (eg. 307 = Temporary Redirect)public RequestProcessor install(RequestProcessor next, io.datatree.Tree config)
install in class HttpMiddlewarepublic java.lang.String getHtmlTemplate()
public void setHtmlTemplate(java.lang.String htmlTemplate)
htmlTemplate - the htmlTemplate to setpublic java.lang.String getLocation()
public void setLocation(java.lang.String location)
location - the location to setpublic int getStatus()
public void setStatus(int status)
status - the status to setpublic java.lang.String getPath()
public void setPath(java.lang.String path)
path - the path to set