Add forward headers
This commit is contained in:
parent
e0bd2a792a
commit
16ca24d329
@ -7,8 +7,6 @@ import io.ktor.server.application.call
|
|||||||
import io.ktor.server.html.respondHtml
|
import io.ktor.server.html.respondHtml
|
||||||
import io.ktor.server.http.content.*
|
import io.ktor.server.http.content.*
|
||||||
import io.ktor.server.plugins.origin
|
import io.ktor.server.plugins.origin
|
||||||
import io.ktor.server.request.host
|
|
||||||
import io.ktor.server.request.port
|
|
||||||
import io.ktor.server.routing.Route
|
import io.ktor.server.routing.Route
|
||||||
import io.ktor.server.routing.createRouteFromPath
|
import io.ktor.server.routing.createRouteFromPath
|
||||||
import io.ktor.server.routing.get
|
import io.ktor.server.routing.get
|
||||||
@ -87,9 +85,10 @@ public class KtorSiteBuilder(
|
|||||||
//substitute host for url for backwards calls
|
//substitute host for url for backwards calls
|
||||||
val url = URLBuilder(baseUrl).apply {
|
val url = URLBuilder(baseUrl).apply {
|
||||||
protocol = URLProtocol.createOrDefault(request.origin.scheme)
|
protocol = URLProtocol.createOrDefault(request.origin.scheme)
|
||||||
host = request.host()
|
host = request.origin.host
|
||||||
port = request.port()
|
port = request.origin.port
|
||||||
}
|
}
|
||||||
|
|
||||||
val pageBuilder = KtorWebPage(url.buildString())
|
val pageBuilder = KtorWebPage(url.buildString())
|
||||||
content(pageBuilder, this)
|
content(pageBuilder, this)
|
||||||
}
|
}
|
||||||
@ -124,21 +123,23 @@ public class KtorSiteBuilder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
context(Route, SnarkEnvironment) private fun siteInRoute(
|
context(Route, SnarkEnvironment) private fun siteInRoute(
|
||||||
|
baseUrl: String = "",
|
||||||
block: KtorSiteBuilder.() -> Unit,
|
block: KtorSiteBuilder.() -> Unit,
|
||||||
) {
|
) {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
block(KtorSiteBuilder(buildHtmlPlugin(), data, meta, "", this@Route))
|
block(KtorSiteBuilder(buildHtmlPlugin(), data, meta, baseUrl, this@Route))
|
||||||
}
|
}
|
||||||
|
|
||||||
context(Application) public fun SnarkEnvironment.site(
|
context(Application) public fun SnarkEnvironment.site(
|
||||||
|
baseUrl: String = "",
|
||||||
block: KtorSiteBuilder.() -> Unit,
|
block: KtorSiteBuilder.() -> Unit,
|
||||||
) {
|
) {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
routing {
|
routing {
|
||||||
siteInRoute(block)
|
siteInRoute(baseUrl, block)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user