try to fix ktor update
This commit is contained in:
parent
c238f391a8
commit
9216c013ec
@ -1,18 +1,16 @@
|
|||||||
package dev.inmo.postssystem.server
|
package dev.inmo.postssystem.server
|
||||||
|
|
||||||
import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator
|
import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator
|
||||||
import io.ktor.application.call
|
import io.ktor.server.http.content.defaultResource
|
||||||
import io.ktor.http.content.*
|
import io.ktor.server.http.content.resources
|
||||||
import io.ktor.response.respondRedirect
|
import io.ktor.server.routing.Route
|
||||||
import io.ktor.routing.Route
|
|
||||||
import io.ktor.routing.get
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class ClientStaticRoutingConfiguration(
|
class ClientStaticRoutingConfiguration(
|
||||||
private val clientStatic: String?
|
private val clientStatic: String?
|
||||||
) : ApplicationRoutingConfigurator.Element {
|
) : ApplicationRoutingConfigurator.Element {
|
||||||
override fun Route.invoke() {
|
override fun Route.invoke() {
|
||||||
resources("web")
|
resources(clientStatic)
|
||||||
defaultResource("/web/index.html")
|
defaultResource("${clientStatic ?.let { "/$it" } ?: ""}/index.html")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,10 @@ import dev.inmo.postssystem.features.content.server.storage.*
|
|||||||
import dev.inmo.postssystem.features.posts.server.*
|
import dev.inmo.postssystem.features.posts.server.*
|
||||||
import dev.inmo.postssystem.features.publication.server.PublicationManager
|
import dev.inmo.postssystem.features.publication.server.PublicationManager
|
||||||
import dev.inmo.postssystem.services.posts.server.*
|
import dev.inmo.postssystem.services.posts.server.*
|
||||||
import io.ktor.application.featureOrNull
|
import io.ktor.server.application.pluginOrNull
|
||||||
import io.ktor.application.log
|
import io.ktor.server.application.log
|
||||||
import io.ktor.routing.Route
|
import io.ktor.server.routing.Route
|
||||||
import io.ktor.routing.Routing
|
import io.ktor.server.routing.Routing
|
||||||
import io.ktor.server.engine.ApplicationEngine
|
import io.ktor.server.engine.ApplicationEngine
|
||||||
import io.ktor.server.netty.Netty
|
import io.ktor.server.netty.Netty
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@ -194,7 +194,7 @@ fun getDIModule(
|
|||||||
it.apply { configure() }
|
it.apply { configure() }
|
||||||
}
|
}
|
||||||
if (config.debugMode) {
|
if (config.debugMode) {
|
||||||
featureOrNull(Routing) ?.print()
|
pluginOrNull(Routing) ?.print()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package dev.inmo.postssystem.server
|
package dev.inmo.postssystem.server
|
||||||
|
|
||||||
import dev.inmo.micro_utils.ktor.server.configurators.StatusPagesConfigurator
|
import dev.inmo.micro_utils.ktor.server.configurators.StatusPagesConfigurator
|
||||||
import io.ktor.application.call
|
import io.ktor.server.application.call
|
||||||
import io.ktor.features.StatusPages
|
|
||||||
import io.ktor.http.HttpStatusCode
|
import io.ktor.http.HttpStatusCode
|
||||||
import io.ktor.response.respondRedirect
|
import io.ktor.server.plugins.statuspages.StatusPagesConfig
|
||||||
|
import io.ktor.server.response.respondRedirect
|
||||||
|
|
||||||
data class NotFoundStatusPageRedirectToIndex(
|
data class NotFoundStatusPageRedirectToIndex(
|
||||||
val redirectTo: String
|
val redirectTo: String
|
||||||
) : StatusPagesConfigurator.Element {
|
) : StatusPagesConfigurator.Element {
|
||||||
override fun StatusPages.Configuration.invoke() {
|
override fun StatusPagesConfig.invoke() {
|
||||||
status(HttpStatusCode.NotFound) {
|
status(HttpStatusCode.NotFound) { _ ->
|
||||||
call.respondRedirect(redirectTo)
|
call.respondRedirect(redirectTo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package dev.inmo.postssystem.server
|
package dev.inmo.postssystem.server
|
||||||
|
|
||||||
import dev.inmo.micro_utils.ktor.server.configurators.KtorApplicationConfigurator
|
import dev.inmo.micro_utils.ktor.server.configurators.KtorApplicationConfigurator
|
||||||
import io.ktor.application.Application
|
import io.ktor.server.application.Application
|
||||||
import io.ktor.application.install
|
import io.ktor.server.application.install
|
||||||
import io.ktor.websocket.WebSockets
|
import io.ktor.server.websocket.WebSockets
|
||||||
|
|
||||||
object WebSocketsConfigurator : KtorApplicationConfigurator {
|
object WebSocketsConfigurator : KtorApplicationConfigurator {
|
||||||
override fun Application.configure() {
|
override fun Application.configure() {
|
||||||
|
Loading…
Reference in New Issue
Block a user