mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-07 00:59:26 +00:00
init with pagination
This commit is contained in:
23
pagination/ktor/server/build.gradle
Normal file
23
pagination/ktor/server/build.gradle
Normal file
@@ -0,0 +1,23 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
}
|
||||
|
||||
apply from: "$mppJavaProjectPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api internalProject("micro_utils.pagination.ktor.common")
|
||||
}
|
||||
}
|
||||
|
||||
jvmMain {
|
||||
dependencies {
|
||||
api "io.ktor:ktor-server:$ktor_version"
|
||||
api "io.ktor:ktor-server-host-common:$ktor_version"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.micro_utils.pagination
|
||||
|
||||
import io.ktor.application.ApplicationCall
|
||||
import io.ktor.http.Parameters
|
||||
|
||||
val Parameters.extractPagination: Pagination
|
||||
get() = SimplePagination(
|
||||
get("page") ?.toIntOrNull() ?: 0,
|
||||
get("size") ?.toIntOrNull() ?: defaultMediumPageSize
|
||||
)
|
||||
|
||||
val ApplicationCall.extractPagination: Pagination
|
||||
get() = request.queryParameters.extractPagination
|
||||
|
Reference in New Issue
Block a user