generated from rnentjes/kotlin-server-web-empty
Set Content-Type header for HTML responses in IndexHandler
Added `Content-Type: text/html` header in `IndexHandler` to ensure correct content type for HTML responses.
This commit is contained in:
@@ -5,12 +5,14 @@ import io.undertow.server.HttpServerExchange
|
|||||||
import io.undertow.server.handlers.PathHandler
|
import io.undertow.server.handlers.PathHandler
|
||||||
import io.undertow.server.handlers.resource.PathResourceManager
|
import io.undertow.server.handlers.resource.PathResourceManager
|
||||||
import io.undertow.server.handlers.resource.ResourceHandler
|
import io.undertow.server.handlers.resource.ResourceHandler
|
||||||
|
import io.undertow.util.Headers
|
||||||
import nl.astraeus.tmpl.itemUrl
|
import nl.astraeus.tmpl.itemUrl
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import kotlin.text.startsWith
|
import kotlin.text.startsWith
|
||||||
|
|
||||||
object IndexHandler : HttpHandler {
|
object IndexHandler : HttpHandler {
|
||||||
override fun handleRequest(exchange: HttpServerExchange) {
|
override fun handleRequest(exchange: HttpServerExchange) {
|
||||||
|
exchange.responseHeaders.put(Headers.CONTENT_TYPE, "text/html")
|
||||||
if (exchange.requestPath.startsWith("/$itemUrl/")) {
|
if (exchange.requestPath.startsWith("/$itemUrl/")) {
|
||||||
exchange.responseSender.send(generateIndex(null))
|
exchange.responseSender.send(generateIndex(null))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user