From 08240d69ab4ca1ea3f599f370498124487e88bfe Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 29 Dec 2023 17:40:38 +0100 Subject: [PATCH] Revert "Redirect 404s to frontend" This reverts commit dfda2f40f1f1a05d6bb3871db79889997b996c4d. --- .../caselaw/config/ErrorHandlerConfig.java | 14 ----------- .../config/ForwardingWebExceptionHandler.java | 25 ------------------- 2 files changed, 39 deletions(-) delete mode 100644 backend/src/main/java/de/bund/digitalservice/ris/caselaw/config/ErrorHandlerConfig.java delete mode 100644 backend/src/main/java/de/bund/digitalservice/ris/caselaw/config/ForwardingWebExceptionHandler.java diff --git a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/config/ErrorHandlerConfig.java b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/config/ErrorHandlerConfig.java deleted file mode 100644 index 88e76b8966..0000000000 --- a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/config/ErrorHandlerConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.bund.digitalservice.ris.caselaw.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.server.WebExceptionHandler; - -@Configuration -public class ErrorHandlerConfig { - - @Bean - public WebExceptionHandler forwardingExceptionHandler() { - return new ForwardingWebExceptionHandler(); - } -} diff --git a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/config/ForwardingWebExceptionHandler.java b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/config/ForwardingWebExceptionHandler.java deleted file mode 100644 index 73d15e8ec2..0000000000 --- a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/config/ForwardingWebExceptionHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.bund.digitalservice.ris.caselaw.config; - -import java.net.URI; -import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; -import org.springframework.web.server.ResponseStatusException; -import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.server.WebExceptionHandler; -import reactor.core.publisher.Mono; - -public class ForwardingWebExceptionHandler implements WebExceptionHandler { - - @Override - public Mono handle(ServerWebExchange exchange, Throwable ex) { - if (ex instanceof ResponseStatusException) { - HttpStatusCode status = ((ResponseStatusException) ex).getStatusCode(); - if (status == HttpStatus.NOT_FOUND) { - exchange.getResponse().setStatusCode(HttpStatus.FOUND); - exchange.getResponse().getHeaders().setLocation(URI.create("/404.index")); - return exchange.getResponse().setComplete(); - } - } - return Mono.error(ex); - } -}