Merge pull request #115 from InsanusMokrassar/0.8.4

0.8.4
This commit is contained in:
InsanusMokrassar 2021-11-19 14:02:38 +06:00 committed by GitHub
commit 89ccaa1b57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 3 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## 0.8.4
* `Ktor`:
* `Server`:
* Several new `createKtorServer`
## 0.8.3
* `Common`:

View File

@ -45,5 +45,5 @@ dokka_version=1.5.31
# Project data
group=dev.inmo
version=0.8.3
android_code_version=83
version=0.8.4
android_code_version=84

View File

@ -1,5 +1,6 @@
package dev.inmo.micro_utils.ktor.server
import dev.inmo.micro_utils.ktor.server.configurators.KtorApplicationConfigurator
import io.ktor.application.Application
import io.ktor.server.cio.CIO
import io.ktor.server.engine.*
@ -31,3 +32,27 @@ fun createKtorServer(
port: Int = Random.nextInt(1024, 65535),
block: Application.() -> Unit
): ApplicationEngine = createKtorServer(CIO, host, port, block)
fun <TEngine : ApplicationEngine, TConfiguration : ApplicationEngine.Configuration> createKtorServer(
engine: ApplicationEngineFactory<TEngine, TConfiguration>,
host: String = "localhost",
port: Int = Random.nextInt(1024, 65535),
configurators: List<KtorApplicationConfigurator>
): TEngine = createKtorServer(
engine,
host,
port
) {
configurators.forEach { it.apply { configure() } }
}
/**
* Create server with [CIO] server engine without starting of it
*
* @see ApplicationEngine.start
*/
fun createKtorServer(
host: String = "localhost",
port: Int = Random.nextInt(1024, 65535),
configurators: List<KtorApplicationConfigurator>
): ApplicationEngine = createKtorServer(CIO, host, port, configurators)

View File

@ -25,7 +25,7 @@ interface Pagination : ClosedRange<Int> {
override val start: Int
get() = page * size
override val endInclusive: Int
get() = lastIndex
get() = start + size - 1
}
fun Pagination.intersect(