publishing keys repo ktor server route now is optional
This commit is contained in:
parent
b9f7d9e346
commit
f5a5330e93
@ -6,19 +6,25 @@ import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigur
|
|||||||
import io.ktor.routing.Route
|
import io.ktor.routing.Route
|
||||||
import io.ktor.routing.route
|
import io.ktor.routing.route
|
||||||
|
|
||||||
|
private inline fun configurator(proxyTo: PublishingKeysRepo): Route.() -> Unit = {
|
||||||
|
configureReadPublishingKeysRepoRoutes(proxyTo)
|
||||||
|
configureWritePublishingKeysRepoRoutes(proxyTo)
|
||||||
|
}
|
||||||
|
|
||||||
fun Route.configurePublishingKeysRepoRoutes (
|
fun Route.configurePublishingKeysRepoRoutes (
|
||||||
proxyTo: PublishingKeysRepo
|
proxyTo: PublishingKeysRepo,
|
||||||
|
rootRoute: String? = publishingKeysRootRoute
|
||||||
) {
|
) {
|
||||||
route(publishingKeysRootRoute) {
|
rootRoute ?.also {
|
||||||
configureReadPublishingKeysRepoRoutes(proxyTo)
|
route(it, configurator(proxyTo))
|
||||||
configureWritePublishingKeysRepoRoutes(proxyTo)
|
} ?: configurator(proxyTo).invoke(this)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PublishingKeysRepoRoutingConfigurator (
|
class PublishingKeysRepoRoutingConfigurator (
|
||||||
private val proxyTo: PublishingKeysRepo
|
private val proxyTo: PublishingKeysRepo,
|
||||||
|
private val rootRoute: String? = publishingKeysRootRoute
|
||||||
) : ApplicationRoutingConfigurator.Element {
|
) : ApplicationRoutingConfigurator.Element {
|
||||||
override fun Route.invoke() {
|
override fun Route.invoke() {
|
||||||
configurePublishingKeysRepoRoutes(proxyTo)
|
configurePublishingKeysRepoRoutes(proxyTo, rootRoute)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user