mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-21 08:07:16 +00:00
doForAllWithCurrentPaging and fun interface for elements in ktor server
This commit is contained in:
parent
6ff3f6ae42
commit
a16815143c
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
## 0.5.10
|
## 0.5.10
|
||||||
|
|
||||||
|
* `Ktor`
|
||||||
|
* `Server`
|
||||||
|
* All elements in configurators became a `fun interface`
|
||||||
|
* `Pagination`
|
||||||
|
* New function `doForAllWithCurrentPaging`
|
||||||
|
|
||||||
## 0.5.9
|
## 0.5.9
|
||||||
|
|
||||||
* `Repos`
|
* `Repos`
|
||||||
|
@ -8,7 +8,7 @@ import kotlinx.serialization.Contextual
|
|||||||
data class ApplicationCachingHeadersConfigurator(
|
data class ApplicationCachingHeadersConfigurator(
|
||||||
private val elements: List<@Contextual Element>
|
private val elements: List<@Contextual Element>
|
||||||
) : KtorApplicationConfigurator {
|
) : KtorApplicationConfigurator {
|
||||||
interface Element { operator fun CachingHeaders.Configuration.invoke() }
|
fun interface Element { operator fun CachingHeaders.Configuration.invoke() }
|
||||||
|
|
||||||
override fun Application.configure() {
|
override fun Application.configure() {
|
||||||
install(CachingHeaders) {
|
install(CachingHeaders) {
|
||||||
|
@ -10,17 +10,18 @@ import kotlinx.serialization.Serializable
|
|||||||
class ApplicationRoutingConfigurator(
|
class ApplicationRoutingConfigurator(
|
||||||
private val elements: List<@Contextual Element>
|
private val elements: List<@Contextual Element>
|
||||||
) : KtorApplicationConfigurator {
|
) : KtorApplicationConfigurator {
|
||||||
interface Element { operator fun Route.invoke() }
|
fun interface Element { operator fun Route.invoke() }
|
||||||
|
private val rootInstaller = Element {
|
||||||
|
elements.forEach {
|
||||||
|
it.apply { invoke() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun Application.configure() {
|
override fun Application.configure() {
|
||||||
try {
|
featureOrNull(Routing) ?.apply {
|
||||||
feature(Routing)
|
rootInstaller.apply { invoke() }
|
||||||
} catch (e: IllegalStateException) {
|
} ?: install(Routing) {
|
||||||
install(Routing) {
|
rootInstaller.apply { invoke() }
|
||||||
elements.forEach {
|
|
||||||
it.apply { invoke() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import kotlinx.serialization.Contextual
|
|||||||
class ApplicationSessionsConfigurator(
|
class ApplicationSessionsConfigurator(
|
||||||
private val elements: List<@Contextual Element>
|
private val elements: List<@Contextual Element>
|
||||||
) : KtorApplicationConfigurator {
|
) : KtorApplicationConfigurator {
|
||||||
interface Element { operator fun Sessions.Configuration.invoke() }
|
fun interface Element { operator fun Sessions.Configuration.invoke() }
|
||||||
|
|
||||||
override fun Application.configure() {
|
override fun Application.configure() {
|
||||||
install(Sessions) {
|
install(Sessions) {
|
||||||
|
@ -8,7 +8,7 @@ import kotlinx.serialization.Contextual
|
|||||||
class StatusPagesConfigurator(
|
class StatusPagesConfigurator(
|
||||||
private val elements: List<@Contextual Element>
|
private val elements: List<@Contextual Element>
|
||||||
) : KtorApplicationConfigurator {
|
) : KtorApplicationConfigurator {
|
||||||
interface Element { operator fun StatusPages.Configuration.invoke() }
|
fun interface Element { operator fun StatusPages.Configuration.invoke() }
|
||||||
|
|
||||||
override fun Application.configure() {
|
override fun Application.configure() {
|
||||||
install(StatusPages) {
|
install(StatusPages) {
|
||||||
|
@ -33,3 +33,8 @@ suspend fun <T> doAllWithCurrentPaging(
|
|||||||
block
|
block
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun <T> doForAllWithCurrentPaging(
|
||||||
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
|
block: suspend (Pagination) -> PaginationResult<T>
|
||||||
|
) = doAllWithCurrentPaging(initialPagination, block)
|
||||||
|
Loading…
Reference in New Issue
Block a user