From 4e444f14d7305e9063b8b84b67c66269f9e960d2 Mon Sep 17 00:00:00 2001 From: Fabian Engelniederhammer Date: Wed, 20 Dec 2023 10:23:25 +0100 Subject: [PATCH] feat: show instance name on "not found" page --- .../org/genspectrum/lapis/controller/ErrorController.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/ErrorController.kt b/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/ErrorController.kt index badaf6f4..39c675c6 100644 --- a/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/ErrorController.kt +++ b/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/ErrorController.kt @@ -3,6 +3,7 @@ package org.genspectrum.lapis.controller import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletResponse import mu.KotlinLogging +import org.genspectrum.lapis.config.DatabaseConfig import org.springframework.boot.autoconfigure.web.ErrorProperties import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController import org.springframework.boot.web.servlet.error.ErrorAttributes @@ -16,7 +17,7 @@ import org.springframework.web.servlet.support.ServletUriComponentsBuilder private val log = KotlinLogging.logger { } @Component -class ErrorController(errorAttributes: ErrorAttributes) : +class ErrorController(private val databaseConfig: DatabaseConfig, errorAttributes: ErrorAttributes) : BasicErrorController(errorAttributes, ErrorProperties()) { @RequestMapping(produces = [MediaType.TEXT_HTML_VALUE]) override fun errorHtml( @@ -32,7 +33,7 @@ class ErrorController(errorAttributes: ErrorAttributes) : log.debug { "Generated url $url to Swagger UI in 'not found page'" } - modelAndView.view = NotFoundView(url) + modelAndView.view = NotFoundView(databaseConfig.schema.instanceName, url) return modelAndView } @@ -42,7 +43,7 @@ class ErrorController(errorAttributes: ErrorAttributes) : } } -data class NotFoundView(private val url: String?) : View { +data class NotFoundView(private val instanceName: String, private val url: String?) : View { override fun render( model: MutableMap?, request: HttpServletRequest, @@ -56,7 +57,7 @@ data class NotFoundView(private val url: String?) : View { Error 404 -

LAPIS

+

LAPIS - $instanceName

Page not found!

Visit our swagger-ui