diff --git a/src/main/kotlin/no/nav/pdfgen/application/api/pdf/GenerateHtmlApi.kt b/src/main/kotlin/no/nav/pdfgen/application/api/pdf/GenerateHtmlApi.kt index 1259fc4..54cb730 100644 --- a/src/main/kotlin/no/nav/pdfgen/application/api/pdf/GenerateHtmlApi.kt +++ b/src/main/kotlin/no/nav/pdfgen/application/api/pdf/GenerateHtmlApi.kt @@ -2,7 +2,6 @@ package no.nav.pdfgen.application.api.pdf import com.fasterxml.jackson.databind.JsonNode import io.ktor.http.* -import io.ktor.server.application.* import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* @@ -13,36 +12,32 @@ import no.nav.pdfgen.logger fun Route.registerGenerateHtmlApi(env: Environment = Environment()) { if (env.enableHtmlEndpoint) { - route("/api/v1/genhtml") { - if (!env.disablePdfGet) { - get("/{applicationName}/{template}") { - val template = call.parameters["template"]!! - val applicationName = call.parameters["applicationName"]!! - createHtmlFromTemplateData(template, applicationName)?.let { call.respond(it) } - ?: call.respondText( - "Template or application not found", - status = HttpStatusCode.NotFound - ) - } - } - - post("/{applicationName}/{template}") { - val startTime = System.currentTimeMillis() + if (!env.disablePdfGet) { + get("/{applicationName}/{template}") { val template = call.parameters["template"]!! val applicationName = call.parameters["applicationName"]!! - val jsonNode: JsonNode = call.receive() - - createHtml(template, applicationName, jsonNode)?.let { - call.respond(it) - logger.info( - "Done generating HTML in ${System.currentTimeMillis() - startTime}ms" - ) - } + createHtmlFromTemplateData(template, applicationName)?.let { call.respond(it) } ?: call.respondText( "Template or application not found", status = HttpStatusCode.NotFound ) } } + + post("/{applicationName}/{template}") { + val startTime = System.currentTimeMillis() + val template = call.parameters["template"]!! + val applicationName = call.parameters["applicationName"]!! + val jsonNode: JsonNode = call.receive() + + createHtml(template, applicationName, jsonNode)?.let { + call.respond(it) + logger.info("Done generating HTML in ${System.currentTimeMillis() - startTime}ms") + } + ?: call.respondText( + "Template or application not found", + status = HttpStatusCode.NotFound + ) + } } } diff --git a/src/main/kotlin/no/nav/pdfgen/plugins/LifecycleHooks.kt b/src/main/kotlin/no/nav/pdfgen/plugins/LifecycleHooks.kt index c4b3784..b957a6f 100644 --- a/src/main/kotlin/no/nav/pdfgen/plugins/LifecycleHooks.kt +++ b/src/main/kotlin/no/nav/pdfgen/plugins/LifecycleHooks.kt @@ -5,9 +5,7 @@ import no.nav.pdfgen.ApplicationState fun Application.configureLifecycleHooks(applicationState: ApplicationState) { - monitor.subscribe(ApplicationStarted) { - applicationState.ready = true - } + monitor.subscribe(ApplicationStarted) { applicationState.ready = true } monitor.subscribe(ApplicationStopped) { applicationState.ready = false applicationState.alive = false diff --git a/src/main/kotlin/no/nav/pdfgen/plugins/StatusPages.kt b/src/main/kotlin/no/nav/pdfgen/plugins/StatusPages.kt index b495129..6a7298e 100644 --- a/src/main/kotlin/no/nav/pdfgen/plugins/StatusPages.kt +++ b/src/main/kotlin/no/nav/pdfgen/plugins/StatusPages.kt @@ -7,7 +7,6 @@ import io.ktor.server.application.* import io.ktor.server.plugins.statuspages.* import io.ktor.server.request.* import io.ktor.server.response.* -import no.nav.pdfgen.ApplicationState import no.nav.pdfgen.logger fun Application.configureStatusPages(