add 410 GONE method

This commit is contained in:
Jörg Prante 2023-03-22 17:39:21 +01:00
parent 1ea725cbc2
commit 65279dbed3

View file

@ -52,10 +52,6 @@ public abstract class DefaultMarkupTemplate extends BaseTemplate {
// session can be null in error templates // session can be null in error templates
} }
public void setResponseStatus(HttpResponseStatus responseStatus) {
responseBuilder.setResponseStatus(responseStatus);
}
public void setContentType(String contentType) { public void setContentType(String contentType) {
responseBuilder.setHeader(HttpHeaderNames.CONTENT_TYPE, contentType); responseBuilder.setHeader(HttpHeaderNames.CONTENT_TYPE, contentType);
} }
@ -76,6 +72,10 @@ public abstract class DefaultMarkupTemplate extends BaseTemplate {
responseBuilder.setHeader(HttpHeaderNames.CONTENT_LENGTH, Integer.toString(contentLength)); responseBuilder.setHeader(HttpHeaderNames.CONTENT_LENGTH, Integer.toString(contentLength));
} }
public void setResponseStatus(HttpResponseStatus responseStatus) {
responseBuilder.setResponseStatus(responseStatus);
}
public void movedPermanently(String url) { public void movedPermanently(String url) {
responseBuilder.setResponseStatus(HttpResponseStatus.MOVED_PERMANENTLY); // 301 responseBuilder.setResponseStatus(HttpResponseStatus.MOVED_PERMANENTLY); // 301
responseBuilder.setHeader(HttpHeaderNames.LOCATION, url); responseBuilder.setHeader(HttpHeaderNames.LOCATION, url);
@ -96,6 +96,14 @@ public abstract class DefaultMarkupTemplate extends BaseTemplate {
responseBuilder.setHeader(HttpHeaderNames.LOCATION, url); responseBuilder.setHeader(HttpHeaderNames.LOCATION, url);
} }
public void notFound() {
responseBuilder.setResponseStatus(HttpResponseStatus.NOT_FOUND); // 404
}
public void gone() {
responseBuilder.setResponseStatus(HttpResponseStatus.GONE); // 410
}
public String contextPath(String rel) { public String contextPath(String rel) {
return urlProto(rel, false); return urlProto(rel, false);
} }