From 65279dbed35dee587ec8a0fb95c4bfec8b954841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Prante?= Date: Wed, 22 Mar 2023 17:39:21 +0100 Subject: [PATCH] add 410 GONE method --- .../template/groovy/DefaultMarkupTemplate.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/net-http-template-groovy/src/main/java/org/xbib/net/http/template/groovy/DefaultMarkupTemplate.java b/net-http-template-groovy/src/main/java/org/xbib/net/http/template/groovy/DefaultMarkupTemplate.java index df2fbd6..6e1c337 100644 --- a/net-http-template-groovy/src/main/java/org/xbib/net/http/template/groovy/DefaultMarkupTemplate.java +++ b/net-http-template-groovy/src/main/java/org/xbib/net/http/template/groovy/DefaultMarkupTemplate.java @@ -52,10 +52,6 @@ public abstract class DefaultMarkupTemplate extends BaseTemplate { // session can be null in error templates } - public void setResponseStatus(HttpResponseStatus responseStatus) { - responseBuilder.setResponseStatus(responseStatus); - } - public void setContentType(String 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)); } + public void setResponseStatus(HttpResponseStatus responseStatus) { + responseBuilder.setResponseStatus(responseStatus); + } + public void movedPermanently(String url) { responseBuilder.setResponseStatus(HttpResponseStatus.MOVED_PERMANENTLY); // 301 responseBuilder.setHeader(HttpHeaderNames.LOCATION, url); @@ -96,6 +96,14 @@ public abstract class DefaultMarkupTemplate extends BaseTemplate { 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) { return urlProto(rel, false); }