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.resource.PathResourceManager
|
||||
import io.undertow.server.handlers.resource.ResourceHandler
|
||||
import io.undertow.util.Headers
|
||||
import nl.astraeus.tmpl.itemUrl
|
||||
import java.nio.file.Paths
|
||||
import kotlin.text.startsWith
|
||||
|
||||
object IndexHandler : HttpHandler {
|
||||
override fun handleRequest(exchange: HttpServerExchange) {
|
||||
exchange.responseHeaders.put(Headers.CONTENT_TYPE, "text/html")
|
||||
if (exchange.requestPath.startsWith("/$itemUrl/")) {
|
||||
exchange.responseSender.send(generateIndex(null))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user