mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-22 16:47:15 +00:00
renames in crud repos and some little refactoring
This commit is contained in:
parent
8d955c4b9d
commit
3bbde61f39
@ -4,13 +4,13 @@ import dev.inmo.micro_utils.pagination.Pagination
|
|||||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
interface ReadStandardCRUDRepo<ObjectType, IdType> : Repo {
|
interface ReadCRUDRepo<ObjectType, IdType> : Repo {
|
||||||
suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType>
|
suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType>
|
||||||
suspend fun getById(id: IdType): ObjectType?
|
suspend fun getById(id: IdType): ObjectType?
|
||||||
suspend fun contains(id: IdType): Boolean
|
suspend fun contains(id: IdType): Boolean
|
||||||
suspend fun count(): Long
|
suspend fun count(): Long
|
||||||
}
|
}
|
||||||
typealias ReadCRUDRepo<ObjectType, IdType> = ReadStandardCRUDRepo<ObjectType, IdType>
|
typealias ReadStandardCRUDRepo<ObjectType, IdType> = ReadCRUDRepo<ObjectType, IdType>
|
||||||
|
|
||||||
typealias UpdatedValuePair<IdType, ValueType> = Pair<IdType, ValueType>
|
typealias UpdatedValuePair<IdType, ValueType> = Pair<IdType, ValueType>
|
||||||
val <IdType> UpdatedValuePair<IdType, *>.id
|
val <IdType> UpdatedValuePair<IdType, *>.id
|
||||||
@ -18,7 +18,7 @@ val <IdType> UpdatedValuePair<IdType, *>.id
|
|||||||
val <ValueType> UpdatedValuePair<*, ValueType>.value
|
val <ValueType> UpdatedValuePair<*, ValueType>.value
|
||||||
get() = second
|
get() = second
|
||||||
|
|
||||||
interface WriteStandardCRUDRepo<ObjectType, IdType, InputValueType> : Repo {
|
interface WriteCRUDRepo<ObjectType, IdType, InputValueType> : Repo {
|
||||||
val newObjectsFlow: Flow<ObjectType>
|
val newObjectsFlow: Flow<ObjectType>
|
||||||
val updatedObjectsFlow: Flow<ObjectType>
|
val updatedObjectsFlow: Flow<ObjectType>
|
||||||
val deletedObjectsIdsFlow: Flow<IdType>
|
val deletedObjectsIdsFlow: Flow<IdType>
|
||||||
@ -28,25 +28,25 @@ interface WriteStandardCRUDRepo<ObjectType, IdType, InputValueType> : Repo {
|
|||||||
suspend fun update(values: List<UpdatedValuePair<IdType, InputValueType>>): List<ObjectType>
|
suspend fun update(values: List<UpdatedValuePair<IdType, InputValueType>>): List<ObjectType>
|
||||||
suspend fun deleteById(ids: List<IdType>)
|
suspend fun deleteById(ids: List<IdType>)
|
||||||
}
|
}
|
||||||
typealias WriteCRUDRepo<ObjectType, IdType, InputValueType> = WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>
|
typealias WriteStandardCRUDRepo<ObjectType, IdType, InputValueType> = WriteCRUDRepo<ObjectType, IdType, InputValueType>
|
||||||
|
|
||||||
suspend fun <ObjectType, IdType, InputValueType> WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>.create(
|
suspend fun <ObjectType, IdType, InputValueType> WriteCRUDRepo<ObjectType, IdType, InputValueType>.create(
|
||||||
vararg values: InputValueType
|
vararg values: InputValueType
|
||||||
): List<ObjectType> = create(values.toList())
|
): List<ObjectType> = create(values.toList())
|
||||||
suspend fun <ObjectType, IdType, InputValueType> WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>.update(
|
suspend fun <ObjectType, IdType, InputValueType> WriteCRUDRepo<ObjectType, IdType, InputValueType>.update(
|
||||||
vararg values: UpdatedValuePair<IdType, InputValueType>
|
vararg values: UpdatedValuePair<IdType, InputValueType>
|
||||||
): List<ObjectType> = update(values.toList())
|
): List<ObjectType> = update(values.toList())
|
||||||
suspend fun <ObjectType, IdType, InputValueType> WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>.deleteById(
|
suspend fun <ObjectType, IdType, InputValueType> WriteCRUDRepo<ObjectType, IdType, InputValueType>.deleteById(
|
||||||
vararg ids: IdType
|
vararg ids: IdType
|
||||||
) = deleteById(ids.toList())
|
) = deleteById(ids.toList())
|
||||||
|
|
||||||
interface StandardCRUDRepo<ObjectType, IdType, InputValueType> : ReadStandardCRUDRepo<ObjectType, IdType>,
|
interface CRUDRepo<ObjectType, IdType, InputValueType> : ReadCRUDRepo<ObjectType, IdType>,
|
||||||
WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>
|
WriteCRUDRepo<ObjectType, IdType, InputValueType>
|
||||||
typealias CRUDRepo<ObjectType, IdType, InputValueType> = StandardCRUDRepo<ObjectType, IdType, InputValueType>
|
typealias StandardCRUDRepo<ObjectType, IdType, InputValueType> = CRUDRepo<ObjectType, IdType, InputValueType>
|
||||||
|
|
||||||
class DelegateBasedStandardCRUDRepo<ObjectType, IdType, InputValueType>(
|
class DelegateBasedCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||||
readDelegate: ReadStandardCRUDRepo<ObjectType, IdType>,
|
readDelegate: ReadCRUDRepo<ObjectType, IdType>,
|
||||||
writeDelegate: WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>
|
writeDelegate: WriteCRUDRepo<ObjectType, IdType, InputValueType>
|
||||||
) : StandardCRUDRepo<ObjectType, IdType, InputValueType>,
|
) : CRUDRepo<ObjectType, IdType, InputValueType>,
|
||||||
ReadStandardCRUDRepo<ObjectType, IdType> by readDelegate,
|
ReadCRUDRepo<ObjectType, IdType> by readDelegate,
|
||||||
WriteStandardCRUDRepo<ObjectType, IdType, InputValueType> by writeDelegate
|
WriteCRUDRepo<ObjectType, IdType, InputValueType> by writeDelegate
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package dev.inmo.micro_utils.repos.pagination
|
package dev.inmo.micro_utils.repos.pagination
|
||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import dev.inmo.micro_utils.pagination.utils.doForAllWithNextPaging
|
|
||||||
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
||||||
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
||||||
|
|
||||||
suspend inline fun <T, ID, REPO : ReadStandardCRUDRepo<T, ID>> REPO.getAll(
|
suspend inline fun <T, ID, REPO : ReadCRUDRepo<T, ID>> REPO.getAll(
|
||||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||||
crossinline methodCaller: suspend REPO.(Pagination) -> PaginationResult<T>
|
crossinline methodCaller: suspend REPO.(Pagination) -> PaginationResult<T>
|
||||||
): List<T> = getAllWithNextPaging {
|
): List<T> = getAllWithNextPaging {
|
||||||
|
@ -12,7 +12,7 @@ val <T> T.asId: String
|
|||||||
|
|
||||||
abstract class AbstractAndroidCRUDRepo<ObjectType, IdType>(
|
abstract class AbstractAndroidCRUDRepo<ObjectType, IdType>(
|
||||||
protected val helper: StandardSQLHelper
|
protected val helper: StandardSQLHelper
|
||||||
) : ReadStandardCRUDRepo<ObjectType, IdType> {
|
) : ReadCRUDRepo<ObjectType, IdType> {
|
||||||
protected abstract val tableName: String
|
protected abstract val tableName: String
|
||||||
protected abstract val idColumnName: String
|
protected abstract val idColumnName: String
|
||||||
protected abstract suspend fun Cursor.toObject(): ObjectType
|
protected abstract suspend fun Cursor.toObject(): ObjectType
|
||||||
@ -64,4 +64,4 @@ abstract class AbstractAndroidCRUDRepo<ObjectType, IdType>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@ abstract class AbstractMutableAndroidCRUDRepo<ObjectType, IdType, InputValueType
|
|||||||
helper: StandardSQLHelper,
|
helper: StandardSQLHelper,
|
||||||
replyInFlows: Int = 0,
|
replyInFlows: Int = 0,
|
||||||
extraBufferCapacityInFlows: Int = 64
|
extraBufferCapacityInFlows: Int = 64
|
||||||
) : WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>,
|
) : WriteCRUDRepo<ObjectType, IdType, InputValueType>,
|
||||||
AbstractAndroidCRUDRepo<ObjectType, IdType>(helper),
|
AbstractAndroidCRUDRepo<ObjectType, IdType>(helper),
|
||||||
StandardCRUDRepo<ObjectType, IdType, InputValueType> {
|
CRUDRepo<ObjectType, IdType, InputValueType> {
|
||||||
protected val newObjectsChannel = MutableSharedFlow<ObjectType>(replyInFlows, extraBufferCapacityInFlows)
|
protected val newObjectsChannel = MutableSharedFlow<ObjectType>(replyInFlows, extraBufferCapacityInFlows)
|
||||||
protected val updateObjectsChannel = MutableSharedFlow<ObjectType>(replyInFlows, extraBufferCapacityInFlows)
|
protected val updateObjectsChannel = MutableSharedFlow<ObjectType>(replyInFlows, extraBufferCapacityInFlows)
|
||||||
protected val deleteObjectsIdsChannel = MutableSharedFlow<IdType>(replyInFlows, extraBufferCapacityInFlows)
|
protected val deleteObjectsIdsChannel = MutableSharedFlow<IdType>(replyInFlows, extraBufferCapacityInFlows)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.micro_utils.repos.exposed
|
package dev.inmo.micro_utils.repos.exposed
|
||||||
|
|
||||||
import dev.inmo.micro_utils.repos.StandardCRUDRepo
|
import dev.inmo.micro_utils.repos.CRUDRepo
|
||||||
|
|
||||||
abstract class AbstractExposedCRUDRepo<ObjectType, IdType, InputValueType>(
|
abstract class AbstractExposedCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||||
flowsChannelsSize: Int = 0,
|
flowsChannelsSize: Int = 0,
|
||||||
@ -11,4 +11,4 @@ abstract class AbstractExposedCRUDRepo<ObjectType, IdType, InputValueType>(
|
|||||||
tableName
|
tableName
|
||||||
),
|
),
|
||||||
ExposedCRUDRepo<ObjectType, IdType>,
|
ExposedCRUDRepo<ObjectType, IdType>,
|
||||||
StandardCRUDRepo<ObjectType, IdType, InputValueType>
|
CRUDRepo<ObjectType, IdType, InputValueType>
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package dev.inmo.micro_utils.repos.exposed
|
package dev.inmo.micro_utils.repos.exposed
|
||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
||||||
import org.jetbrains.exposed.sql.*
|
import org.jetbrains.exposed.sql.*
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
abstract class AbstractExposedReadCRUDRepo<ObjectType, IdType>(
|
abstract class AbstractExposedReadCRUDRepo<ObjectType, IdType>(
|
||||||
tableName: String
|
tableName: String
|
||||||
) :
|
) :
|
||||||
ReadStandardCRUDRepo<ObjectType, IdType>,
|
ReadCRUDRepo<ObjectType, IdType>,
|
||||||
ExposedCRUDRepo<ObjectType, IdType>,
|
ExposedCRUDRepo<ObjectType, IdType>,
|
||||||
Table(tableName)
|
Table(tableName)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos.exposed
|
package dev.inmo.micro_utils.repos.exposed
|
||||||
|
|
||||||
import dev.inmo.micro_utils.repos.UpdatedValuePair
|
import dev.inmo.micro_utils.repos.UpdatedValuePair
|
||||||
import dev.inmo.micro_utils.repos.WriteStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.WriteCRUDRepo
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
import org.jetbrains.exposed.sql.*
|
import org.jetbrains.exposed.sql.*
|
||||||
import org.jetbrains.exposed.sql.statements.InsertStatement
|
import org.jetbrains.exposed.sql.statements.InsertStatement
|
||||||
@ -15,7 +15,7 @@ abstract class AbstractExposedWriteCRUDRepo<ObjectType, IdType, InputValueType>(
|
|||||||
) :
|
) :
|
||||||
AbstractExposedReadCRUDRepo<ObjectType, IdType>(tableName),
|
AbstractExposedReadCRUDRepo<ObjectType, IdType>(tableName),
|
||||||
ExposedCRUDRepo<ObjectType, IdType>,
|
ExposedCRUDRepo<ObjectType, IdType>,
|
||||||
WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>
|
WriteCRUDRepo<ObjectType, IdType, InputValueType>
|
||||||
{
|
{
|
||||||
protected val _newObjectsFlow = MutableSharedFlow<ObjectType>(replyCacheInFlows, flowsChannelsSize)
|
protected val _newObjectsFlow = MutableSharedFlow<ObjectType>(replyCacheInFlows, flowsChannelsSize)
|
||||||
protected val _updatedObjectsFlow = MutableSharedFlow<ObjectType>(replyCacheInFlows, flowsChannelsSize)
|
protected val _updatedObjectsFlow = MutableSharedFlow<ObjectType>(replyCacheInFlows, flowsChannelsSize)
|
||||||
|
@ -5,7 +5,7 @@ import kotlinx.coroutines.flow.*
|
|||||||
|
|
||||||
class ReadMapCRUDRepo<ObjectType, IdType>(
|
class ReadMapCRUDRepo<ObjectType, IdType>(
|
||||||
private val map: Map<IdType, ObjectType> = emptyMap()
|
private val map: Map<IdType, ObjectType> = emptyMap()
|
||||||
) : ReadStandardCRUDRepo<ObjectType, IdType> {
|
) : ReadCRUDRepo<ObjectType, IdType> {
|
||||||
override suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType> {
|
override suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType> {
|
||||||
return map.keys.drop(pagination.firstIndex).take(pagination.size).mapNotNull {
|
return map.keys.drop(pagination.firstIndex).take(pagination.size).mapNotNull {
|
||||||
map[it]
|
map[it]
|
||||||
@ -24,7 +24,7 @@ class ReadMapCRUDRepo<ObjectType, IdType>(
|
|||||||
|
|
||||||
abstract class WriteMapCRUDRepo<ObjectType, IdType, InputValueType>(
|
abstract class WriteMapCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||||
protected val map: MutableMap<IdType, ObjectType> = mutableMapOf()
|
protected val map: MutableMap<IdType, ObjectType> = mutableMapOf()
|
||||||
) : WriteStandardCRUDRepo<ObjectType, IdType, InputValueType> {
|
) : WriteCRUDRepo<ObjectType, IdType, InputValueType> {
|
||||||
protected val _newObjectsFlow: MutableSharedFlow<ObjectType> = MutableSharedFlow()
|
protected val _newObjectsFlow: MutableSharedFlow<ObjectType> = MutableSharedFlow()
|
||||||
override val newObjectsFlow: Flow<ObjectType> = _newObjectsFlow.asSharedFlow()
|
override val newObjectsFlow: Flow<ObjectType> = _newObjectsFlow.asSharedFlow()
|
||||||
protected val _updatedObjectsFlow: MutableSharedFlow<ObjectType> = MutableSharedFlow()
|
protected val _updatedObjectsFlow: MutableSharedFlow<ObjectType> = MutableSharedFlow()
|
||||||
@ -68,8 +68,8 @@ abstract class WriteMapCRUDRepo<ObjectType, IdType, InputValueType>(
|
|||||||
|
|
||||||
abstract class MapCRUDRepo<ObjectType, IdType, InputValueType>(
|
abstract class MapCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||||
map: MutableMap<IdType, ObjectType>
|
map: MutableMap<IdType, ObjectType>
|
||||||
) : StandardCRUDRepo<ObjectType, IdType, InputValueType>,
|
) : CRUDRepo<ObjectType, IdType, InputValueType>,
|
||||||
ReadStandardCRUDRepo<ObjectType, IdType> by ReadMapCRUDRepo(map),
|
ReadCRUDRepo<ObjectType, IdType> by ReadMapCRUDRepo(map),
|
||||||
WriteMapCRUDRepo<ObjectType, IdType, InputValueType>(map)
|
WriteMapCRUDRepo<ObjectType, IdType, InputValueType>(map)
|
||||||
|
|
||||||
fun <ObjectType, IdType, InputValueType> MapCRUDRepo(
|
fun <ObjectType, IdType, InputValueType> MapCRUDRepo(
|
||||||
|
@ -3,16 +3,15 @@ package dev.inmo.micro_utils.repos.ktor.client.crud
|
|||||||
import dev.inmo.micro_utils.ktor.common.*
|
import dev.inmo.micro_utils.ktor.common.*
|
||||||
import dev.inmo.micro_utils.repos.*
|
import dev.inmo.micro_utils.repos.*
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.utils.EmptyContent.contentType
|
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.util.reflect.TypeInfo
|
import io.ktor.util.reflect.TypeInfo
|
||||||
import io.ktor.util.reflect.typeInfo
|
import io.ktor.util.reflect.typeInfo
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
class KtorStandardCrudRepoClient<ObjectType, IdType, InputValue> (
|
class KtorCRUDRepoClient<ObjectType, IdType, InputValue> (
|
||||||
readDelegate: ReadStandardCRUDRepo<ObjectType, IdType>,
|
readDelegate: ReadCRUDRepo<ObjectType, IdType>,
|
||||||
writeDelegate: WriteStandardCRUDRepo<ObjectType, IdType, InputValue>
|
writeDelegate: WriteCRUDRepo<ObjectType, IdType, InputValue>
|
||||||
) : StandardCRUDRepo<ObjectType, IdType, InputValue> by DelegateBasedStandardCRUDRepo(
|
) : CRUDRepo<ObjectType, IdType, InputValue> by DelegateBasedCRUDRepo(
|
||||||
readDelegate,
|
readDelegate,
|
||||||
writeDelegate
|
writeDelegate
|
||||||
) {
|
) {
|
||||||
@ -23,15 +22,15 @@ class KtorStandardCrudRepoClient<ObjectType, IdType, InputValue> (
|
|||||||
objectTypeInfo: TypeInfo,
|
objectTypeInfo: TypeInfo,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
noinline idSerializer: suspend (IdType) -> String
|
noinline idSerializer: suspend (IdType) -> String
|
||||||
) = KtorStandardCrudRepoClient(
|
) = KtorCRUDRepoClient(
|
||||||
KtorReadStandardCrudRepoClient(
|
KtorReadCRUDRepoClient(
|
||||||
baseUrl,
|
baseUrl,
|
||||||
httpClient,
|
httpClient,
|
||||||
objectTypeInfo,
|
objectTypeInfo,
|
||||||
contentType,
|
contentType,
|
||||||
idSerializer
|
idSerializer
|
||||||
),
|
),
|
||||||
KtorWriteStandardCrudRepoClient<ObjectType, IdType, InputValue>(
|
KtorWriteCrudRepoClient<ObjectType, IdType, InputValue>(
|
||||||
baseUrl,
|
baseUrl,
|
||||||
httpClient,
|
httpClient,
|
||||||
contentType
|
contentType
|
||||||
@ -45,7 +44,7 @@ class KtorStandardCrudRepoClient<ObjectType, IdType, InputValue> (
|
|||||||
objectTypeInfo: TypeInfo,
|
objectTypeInfo: TypeInfo,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
noinline idSerializer: suspend (IdType) -> String
|
noinline idSerializer: suspend (IdType) -> String
|
||||||
) = KtorStandardCrudRepoClient<ObjectType, IdType, InputValue>(
|
) = KtorCRUDRepoClient<ObjectType, IdType, InputValue>(
|
||||||
buildStandardUrl(baseUrl, subpart),
|
buildStandardUrl(baseUrl, subpart),
|
||||||
httpClient,
|
httpClient,
|
||||||
objectTypeInfo,
|
objectTypeInfo,
|
||||||
@ -56,12 +55,12 @@ class KtorStandardCrudRepoClient<ObjectType, IdType, InputValue> (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorStandardCrudRepoClient(
|
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorCRUDRepoClient(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
httpClient: HttpClient,
|
httpClient: HttpClient,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
noinline idSerializer: suspend (IdType) -> String
|
noinline idSerializer: suspend (IdType) -> String
|
||||||
) = KtorStandardCrudRepoClient<ObjectType, IdType, InputValue>(
|
) = KtorCRUDRepoClient<ObjectType, IdType, InputValue>(
|
||||||
baseUrl,
|
baseUrl,
|
||||||
httpClient,
|
httpClient,
|
||||||
typeInfo<ObjectType>(),
|
typeInfo<ObjectType>(),
|
||||||
@ -69,54 +68,54 @@ inline fun <reified ObjectType, reified IdType, reified InputValue> KtorStandard
|
|||||||
idSerializer
|
idSerializer
|
||||||
)
|
)
|
||||||
|
|
||||||
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorStandardCrudRepoClient(
|
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorCRUDRepoClient(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
httpClient: HttpClient,
|
httpClient: HttpClient,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: StringFormat,
|
serialFormat: StringFormat,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
) = KtorStandardCrudRepoClient<ObjectType, IdType, InputValue>(baseUrl, httpClient, contentType) {
|
) = KtorCRUDRepoClient<ObjectType, IdType, InputValue>(baseUrl, httpClient, contentType) {
|
||||||
serialFormat.encodeToString(idsSerializer, it)
|
serialFormat.encodeToString(idsSerializer, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorStandardCrudRepoClient(
|
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorCRUDRepoClient(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
httpClient: HttpClient,
|
httpClient: HttpClient,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: BinaryFormat,
|
serialFormat: BinaryFormat,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
) = KtorStandardCrudRepoClient<ObjectType, IdType, InputValue>(baseUrl, httpClient, contentType) {
|
) = KtorCRUDRepoClient<ObjectType, IdType, InputValue>(baseUrl, httpClient, contentType) {
|
||||||
serialFormat.encodeHex(idsSerializer, it)
|
serialFormat.encodeHex(idsSerializer, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorStandardCrudRepoClient(
|
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorCRUDRepoClient(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
subpart: String,
|
subpart: String,
|
||||||
httpClient: HttpClient,
|
httpClient: HttpClient,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
noinline idSerializer: suspend (IdType) -> String
|
noinline idSerializer: suspend (IdType) -> String
|
||||||
) = KtorStandardCrudRepoClient<ObjectType, IdType, InputValue>(
|
) = KtorCRUDRepoClient<ObjectType, IdType, InputValue>(
|
||||||
buildStandardUrl(baseUrl, subpart),
|
buildStandardUrl(baseUrl, subpart),
|
||||||
httpClient,
|
httpClient,
|
||||||
contentType,
|
contentType,
|
||||||
idSerializer
|
idSerializer
|
||||||
)
|
)
|
||||||
|
|
||||||
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorStandardCrudRepoClient(
|
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorCRUDRepoClient(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
subpart: String,
|
subpart: String,
|
||||||
httpClient: HttpClient,
|
httpClient: HttpClient,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: StringFormat,
|
serialFormat: StringFormat,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
) = KtorStandardCrudRepoClient<ObjectType, IdType, InputValue>(buildStandardUrl(baseUrl, subpart), httpClient, idsSerializer, serialFormat, contentType)
|
) = KtorCRUDRepoClient<ObjectType, IdType, InputValue>(buildStandardUrl(baseUrl, subpart), httpClient, idsSerializer, serialFormat, contentType)
|
||||||
|
|
||||||
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorStandardCrudRepoClient(
|
inline fun <reified ObjectType, reified IdType, reified InputValue> KtorCRUDRepoClient(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
subpart: String,
|
subpart: String,
|
||||||
httpClient: HttpClient,
|
httpClient: HttpClient,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: BinaryFormat,
|
serialFormat: BinaryFormat,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
) = KtorStandardCrudRepoClient<ObjectType, IdType, InputValue>(buildStandardUrl(baseUrl, subpart), httpClient, idsSerializer, serialFormat, contentType)
|
) = KtorCRUDRepoClient<ObjectType, IdType, InputValue>(buildStandardUrl(baseUrl, subpart), httpClient, idsSerializer, serialFormat, contentType)
|
@ -2,7 +2,7 @@ package dev.inmo.micro_utils.repos.ktor.client.crud
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.ktor.common.*
|
import dev.inmo.micro_utils.ktor.common.*
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.countRouting
|
import dev.inmo.micro_utils.repos.ktor.common.countRouting
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.idParameterName
|
import dev.inmo.micro_utils.repos.ktor.common.idParameterName
|
||||||
@ -14,13 +14,13 @@ import io.ktor.util.reflect.TypeInfo
|
|||||||
import io.ktor.util.reflect.typeInfo
|
import io.ktor.util.reflect.typeInfo
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
class KtorReadStandardCrudRepoClient<ObjectType, IdType> (
|
class KtorReadCRUDRepoClient<ObjectType, IdType> (
|
||||||
private val baseUrl: String,
|
private val baseUrl: String,
|
||||||
private val httpClient: HttpClient,
|
private val httpClient: HttpClient,
|
||||||
private val objectType: TypeInfo,
|
private val objectType: TypeInfo,
|
||||||
private val contentType: ContentType,
|
private val contentType: ContentType,
|
||||||
private val idSerializer: suspend (IdType) -> String
|
private val idSerializer: suspend (IdType) -> String
|
||||||
) : ReadStandardCRUDRepo<ObjectType, IdType> {
|
) : ReadCRUDRepo<ObjectType, IdType> {
|
||||||
override suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType> = httpClient.get(
|
override suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType> = httpClient.get(
|
||||||
buildStandardUrl(baseUrl, getByPaginationRouting, pagination.asUrlQueryParts)
|
buildStandardUrl(baseUrl, getByPaginationRouting, pagination.asUrlQueryParts)
|
||||||
) {
|
) {
|
||||||
@ -61,12 +61,12 @@ class KtorReadStandardCrudRepoClient<ObjectType, IdType> (
|
|||||||
}.body()
|
}.body()
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified ObjectType, IdType> KtorReadStandardCrudRepoClient(
|
inline fun <reified ObjectType, IdType> KtorReadCRUDRepoClient(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
httpClient: HttpClient,
|
httpClient: HttpClient,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
noinline idSerializer: suspend (IdType) -> String
|
noinline idSerializer: suspend (IdType) -> String
|
||||||
) = KtorReadStandardCrudRepoClient<ObjectType, IdType>(
|
) = KtorReadCRUDRepoClient<ObjectType, IdType>(
|
||||||
baseUrl,
|
baseUrl,
|
||||||
httpClient,
|
httpClient,
|
||||||
typeInfo<ObjectType>(),
|
typeInfo<ObjectType>(),
|
||||||
@ -74,22 +74,22 @@ inline fun <reified ObjectType, IdType> KtorReadStandardCrudRepoClient(
|
|||||||
idSerializer
|
idSerializer
|
||||||
)
|
)
|
||||||
|
|
||||||
inline fun <reified ObjectType, IdType> KtorReadStandardCrudRepoClient(
|
inline fun <reified ObjectType, IdType> KtorReadCRUDRepoClient(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
httpClient: HttpClient,
|
httpClient: HttpClient,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: StringFormat,
|
serialFormat: StringFormat,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
) = KtorReadStandardCrudRepoClient<ObjectType, IdType>(baseUrl, httpClient, contentType) {
|
) = KtorReadCRUDRepoClient<ObjectType, IdType>(baseUrl, httpClient, contentType) {
|
||||||
serialFormat.encodeToString(idsSerializer, it)
|
serialFormat.encodeToString(idsSerializer, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified ObjectType, IdType> KtorReadStandardCrudRepoClient(
|
inline fun <reified ObjectType, IdType> KtorReadCRUDRepoClient(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
httpClient: HttpClient,
|
httpClient: HttpClient,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: BinaryFormat,
|
serialFormat: BinaryFormat,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
) = KtorReadStandardCrudRepoClient<ObjectType, IdType>(baseUrl, httpClient, contentType) {
|
) = KtorReadCRUDRepoClient<ObjectType, IdType>(baseUrl, httpClient, contentType) {
|
||||||
serialFormat.encodeHex(idsSerializer, it)
|
serialFormat.encodeHex(idsSerializer, it)
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ package dev.inmo.micro_utils.repos.ktor.client.crud
|
|||||||
import dev.inmo.micro_utils.ktor.client.*
|
import dev.inmo.micro_utils.ktor.client.*
|
||||||
import dev.inmo.micro_utils.ktor.common.*
|
import dev.inmo.micro_utils.ktor.common.*
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.countRouting
|
import dev.inmo.micro_utils.repos.ktor.common.countRouting
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.idParameterName
|
import dev.inmo.micro_utils.repos.ktor.common.idParameterName
|
||||||
@ -11,14 +11,14 @@ import io.ktor.client.HttpClient
|
|||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Deprecated("Use KtorReadStandardCrudRepoClient instead")
|
@Deprecated("Use KtorReadCRUDRepoClient instead")
|
||||||
class KtorReadStandardCrudRepo<ObjectType, IdType> (
|
class KtorReadStandardCrudRepo<ObjectType, IdType> (
|
||||||
private val baseUrl: String,
|
private val baseUrl: String,
|
||||||
private val unifiedRequester: UnifiedRequester,
|
private val unifiedRequester: UnifiedRequester,
|
||||||
private val objectsSerializer: KSerializer<ObjectType>,
|
private val objectsSerializer: KSerializer<ObjectType>,
|
||||||
private val objectsSerializerNullable: KSerializer<ObjectType?>,
|
private val objectsSerializerNullable: KSerializer<ObjectType?>,
|
||||||
private val idsSerializer: KSerializer<IdType>
|
private val idsSerializer: KSerializer<IdType>
|
||||||
) : ReadStandardCRUDRepo<ObjectType, IdType> {
|
) : ReadCRUDRepo<ObjectType, IdType> {
|
||||||
private val paginationResultSerializer = PaginationResult.serializer(objectsSerializer)
|
private val paginationResultSerializer = PaginationResult.serializer(objectsSerializer)
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -7,7 +7,7 @@ import dev.inmo.micro_utils.repos.*
|
|||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
|
|
||||||
@Deprecated("Use KtorStandardCrudRepoClient instead")
|
@Deprecated("Use KtorCRUDRepoClient instead")
|
||||||
class KtorStandardCrudRepo<ObjectType, IdType, InputValue> (
|
class KtorStandardCrudRepo<ObjectType, IdType, InputValue> (
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
baseSubpart: String,
|
baseSubpart: String,
|
||||||
@ -16,15 +16,15 @@ class KtorStandardCrudRepo<ObjectType, IdType, InputValue> (
|
|||||||
objectsNullableSerializer: KSerializer<ObjectType?>,
|
objectsNullableSerializer: KSerializer<ObjectType?>,
|
||||||
inputsSerializer: KSerializer<InputValue>,
|
inputsSerializer: KSerializer<InputValue>,
|
||||||
idsSerializer: KSerializer<IdType>
|
idsSerializer: KSerializer<IdType>
|
||||||
) : StandardCRUDRepo<ObjectType, IdType, InputValue>,
|
) : CRUDRepo<ObjectType, IdType, InputValue>,
|
||||||
ReadStandardCRUDRepo<ObjectType, IdType> by KtorReadStandardCrudRepo(
|
ReadCRUDRepo<ObjectType, IdType> by KtorReadStandardCrudRepo(
|
||||||
"$baseUrl/$baseSubpart",
|
"$baseUrl/$baseSubpart",
|
||||||
unifiedRequester,
|
unifiedRequester,
|
||||||
objectsSerializer,
|
objectsSerializer,
|
||||||
objectsNullableSerializer,
|
objectsNullableSerializer,
|
||||||
idsSerializer
|
idsSerializer
|
||||||
),
|
),
|
||||||
WriteStandardCRUDRepo<ObjectType, IdType, InputValue> by KtorWriteStandardCrudRepo(
|
WriteCRUDRepo<ObjectType, IdType, InputValue> by KtorWriteStandardCrudRepo(
|
||||||
"$baseUrl/$baseSubpart",
|
"$baseUrl/$baseSubpart",
|
||||||
unifiedRequester,
|
unifiedRequester,
|
||||||
objectsSerializer,
|
objectsSerializer,
|
||||||
|
@ -3,7 +3,7 @@ package dev.inmo.micro_utils.repos.ktor.client.crud
|
|||||||
import dev.inmo.micro_utils.ktor.client.*
|
import dev.inmo.micro_utils.ktor.client.*
|
||||||
import dev.inmo.micro_utils.ktor.common.*
|
import dev.inmo.micro_utils.ktor.common.*
|
||||||
import dev.inmo.micro_utils.repos.UpdatedValuePair
|
import dev.inmo.micro_utils.repos.UpdatedValuePair
|
||||||
import dev.inmo.micro_utils.repos.WriteStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.WriteCRUDRepo
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.call.body
|
import io.ktor.client.call.body
|
||||||
@ -13,7 +13,7 @@ import io.ktor.http.ContentType
|
|||||||
import io.ktor.http.contentType
|
import io.ktor.http.contentType
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
class KtorWriteStandardCrudRepoClient<ObjectType, IdType, InputValue> (
|
class KtorWriteCrudRepoClient<ObjectType, IdType, InputValue> (
|
||||||
private val baseUrl: String,
|
private val baseUrl: String,
|
||||||
private val httpClient: HttpClient,
|
private val httpClient: HttpClient,
|
||||||
override val newObjectsFlow: Flow<ObjectType>,
|
override val newObjectsFlow: Flow<ObjectType>,
|
||||||
@ -24,7 +24,7 @@ class KtorWriteStandardCrudRepoClient<ObjectType, IdType, InputValue> (
|
|||||||
private val deleteByIdSetup: suspend HttpRequestBuilder.(List<IdType>) -> Unit,
|
private val deleteByIdSetup: suspend HttpRequestBuilder.(List<IdType>) -> Unit,
|
||||||
private val createBodyGetter: suspend HttpResponse.() -> List<ObjectType>,
|
private val createBodyGetter: suspend HttpResponse.() -> List<ObjectType>,
|
||||||
private val updateBodyGetter: suspend HttpResponse.() -> List<ObjectType>
|
private val updateBodyGetter: suspend HttpResponse.() -> List<ObjectType>
|
||||||
) : WriteStandardCRUDRepo<ObjectType, IdType, InputValue> {
|
) : WriteCRUDRepo<ObjectType, IdType, InputValue> {
|
||||||
override suspend fun create(values: List<InputValue>): List<ObjectType> = httpClient.post(
|
override suspend fun create(values: List<InputValue>): List<ObjectType> = httpClient.post(
|
||||||
buildStandardUrl(baseUrl, createRouting)
|
buildStandardUrl(baseUrl, createRouting)
|
||||||
) {
|
) {
|
||||||
@ -54,7 +54,7 @@ class KtorWriteStandardCrudRepoClient<ObjectType, IdType, InputValue> (
|
|||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
httpClient: HttpClient,
|
httpClient: HttpClient,
|
||||||
contentType: ContentType
|
contentType: ContentType
|
||||||
) = KtorWriteStandardCrudRepoClient<ObjectType, IdType, InputValue>(
|
) = KtorWriteCrudRepoClient<ObjectType, IdType, InputValue>(
|
||||||
baseUrl,
|
baseUrl,
|
||||||
httpClient,
|
httpClient,
|
||||||
httpClient.createStandardWebsocketFlow(
|
httpClient.createStandardWebsocketFlow(
|
@ -3,14 +3,14 @@ package dev.inmo.micro_utils.repos.ktor.client.crud
|
|||||||
import dev.inmo.micro_utils.ktor.client.*
|
import dev.inmo.micro_utils.ktor.client.*
|
||||||
import dev.inmo.micro_utils.ktor.common.*
|
import dev.inmo.micro_utils.ktor.common.*
|
||||||
import dev.inmo.micro_utils.repos.UpdatedValuePair
|
import dev.inmo.micro_utils.repos.UpdatedValuePair
|
||||||
import dev.inmo.micro_utils.repos.WriteStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.WriteCRUDRepo
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.*
|
import kotlinx.serialization.builtins.*
|
||||||
|
|
||||||
@Deprecated("Use KtorWriteStandardCrudRepoClient instead")
|
@Deprecated("Use KtorWriteCRUDRepoClient instead")
|
||||||
class KtorWriteStandardCrudRepo<ObjectType, IdType, InputValue> (
|
class KtorWriteStandardCrudRepo<ObjectType, IdType, InputValue> (
|
||||||
private val baseUrl: String,
|
private val baseUrl: String,
|
||||||
private val unifiedRequester: UnifiedRequester,
|
private val unifiedRequester: UnifiedRequester,
|
||||||
@ -18,7 +18,7 @@ class KtorWriteStandardCrudRepo<ObjectType, IdType, InputValue> (
|
|||||||
private val objectsNullableSerializer: KSerializer<ObjectType?>,
|
private val objectsNullableSerializer: KSerializer<ObjectType?>,
|
||||||
private val inputsSerializer: KSerializer<InputValue>,
|
private val inputsSerializer: KSerializer<InputValue>,
|
||||||
private val idsSerializer: KSerializer<IdType>
|
private val idsSerializer: KSerializer<IdType>
|
||||||
) : WriteStandardCRUDRepo<ObjectType, IdType, InputValue> {
|
) : WriteCRUDRepo<ObjectType, IdType, InputValue> {
|
||||||
private val listObjectsSerializer = ListSerializer(objectsSerializer)
|
private val listObjectsSerializer = ListSerializer(objectsSerializer)
|
||||||
private val listInputSerializer = ListSerializer(inputsSerializer)
|
private val listInputSerializer = ListSerializer(inputsSerializer)
|
||||||
private val listIdsSerializer = ListSerializer(idsSerializer)
|
private val listIdsSerializer = ListSerializer(idsSerializer)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import dev.inmo.micro_utils.repos.*
|
import dev.inmo.micro_utils.repos.*
|
||||||
import dev.inmo.micro_utils.repos.ktor.client.crud.KtorStandardCrudRepoClient
|
import dev.inmo.micro_utils.repos.ktor.client.crud.KtorCRUDRepoClient
|
||||||
import dev.inmo.micro_utils.repos.ktor.server.crud.configureStandardCrudRepoRoutes
|
import dev.inmo.micro_utils.repos.ktor.server.crud.configureCRUDRepoRoutes
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.plugins.logging.Logging
|
import io.ktor.client.plugins.logging.Logging
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
@ -43,7 +43,7 @@ class CRUDTests {
|
|||||||
contentConverter = KotlinxWebsocketSerializationConverter(Json)
|
contentConverter = KotlinxWebsocketSerializationConverter(Json)
|
||||||
}
|
}
|
||||||
routing {
|
routing {
|
||||||
configureStandardCrudRepoRoutes(
|
configureCRUDRepoRoutes(
|
||||||
repo
|
repo
|
||||||
) {
|
) {
|
||||||
it.toInt()
|
it.toInt()
|
||||||
@ -59,7 +59,7 @@ class CRUDTests {
|
|||||||
contentConverter = KotlinxWebsocketSerializationConverter(Json)
|
contentConverter = KotlinxWebsocketSerializationConverter(Json)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val crudClient = KtorStandardCrudRepoClient<ComplexData, Int, SimpleData>(
|
val crudClient = KtorCRUDRepoClient<ComplexData, Int, SimpleData>(
|
||||||
"http://127.0.0.1:23456",
|
"http://127.0.0.1:23456",
|
||||||
client,
|
client,
|
||||||
ContentType.Application.Json
|
ContentType.Application.Json
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package dev.inmo.micro_utils.repos.ktor.server.crud
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.ktor.common.*
|
||||||
|
import dev.inmo.micro_utils.repos.CRUDRepo
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
inline fun <reified ObjectType : Any, reified IdType : Any, reified InputValue : Any> Route.configureCRUDRepoRoutes(
|
||||||
|
originalRepo: CRUDRepo<ObjectType, IdType, InputValue>,
|
||||||
|
noinline idDeserializer: suspend (String) -> IdType
|
||||||
|
) {
|
||||||
|
configureReadCRUDRepoRoutes(originalRepo, idDeserializer)
|
||||||
|
configureWriteCRUDRepoRoutes(originalRepo)
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <reified ObjectType : Any, reified IdType : Any, reified InputValue : Any> Route.configureCRUDRepoRoutes(
|
||||||
|
originalRepo: CRUDRepo<ObjectType, IdType, InputValue>,
|
||||||
|
idsSerializer: KSerializer<IdType>,
|
||||||
|
serialFormat: StringFormat
|
||||||
|
) = configureCRUDRepoRoutes(originalRepo) {
|
||||||
|
serialFormat.decodeFromString(idsSerializer, it)
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <reified ObjectType : Any, reified IdType : Any, reified InputValue : Any> Route.configureCRUDRepoRoutes(
|
||||||
|
originalRepo: CRUDRepo<ObjectType, IdType, InputValue>,
|
||||||
|
idsSerializer: KSerializer<IdType>,
|
||||||
|
serialFormat: BinaryFormat
|
||||||
|
) = configureCRUDRepoRoutes(originalRepo) {
|
||||||
|
serialFormat.decodeHex(idsSerializer, it)
|
||||||
|
}
|
@ -3,11 +3,10 @@ package dev.inmo.micro_utils.repos.ktor.server.crud
|
|||||||
import dev.inmo.micro_utils.ktor.common.decodeHex
|
import dev.inmo.micro_utils.ktor.common.decodeHex
|
||||||
import dev.inmo.micro_utils.ktor.server.*
|
import dev.inmo.micro_utils.ktor.server.*
|
||||||
import dev.inmo.micro_utils.pagination.extractPagination
|
import dev.inmo.micro_utils.pagination.extractPagination
|
||||||
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.countRouting
|
import dev.inmo.micro_utils.repos.ktor.common.countRouting
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.idParameterName
|
import dev.inmo.micro_utils.repos.ktor.common.idParameterName
|
||||||
import io.ktor.http.ContentType
|
|
||||||
import io.ktor.http.HttpStatusCode
|
import io.ktor.http.HttpStatusCode
|
||||||
import io.ktor.server.application.call
|
import io.ktor.server.application.call
|
||||||
import io.ktor.server.response.respond
|
import io.ktor.server.response.respond
|
||||||
@ -15,8 +14,8 @@ import io.ktor.server.routing.Route
|
|||||||
import io.ktor.server.routing.get
|
import io.ktor.server.routing.get
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
inline fun <reified ObjectType, reified IdType> Route.configureReadStandardCrudRepoRoutes(
|
inline fun <reified ObjectType, reified IdType> Route.configureReadCRUDRepoRoutes(
|
||||||
originalRepo: ReadStandardCRUDRepo<ObjectType, IdType>,
|
originalRepo: ReadCRUDRepo<ObjectType, IdType>,
|
||||||
noinline idDeserializer: suspend (String) -> IdType
|
noinline idDeserializer: suspend (String) -> IdType
|
||||||
) {
|
) {
|
||||||
get(getByPaginationRouting) {
|
get(getByPaginationRouting) {
|
||||||
@ -56,18 +55,18 @@ inline fun <reified ObjectType, reified IdType> Route.configureReadStandardCrudR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified ObjectType, reified IdType> Route.configureReadStandardCrudRepoRoutes(
|
inline fun <reified ObjectType, reified IdType> Route.configureReadCRUDRepoRoutes(
|
||||||
originalRepo: ReadStandardCRUDRepo<ObjectType, IdType>,
|
originalRepo: ReadCRUDRepo<ObjectType, IdType>,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: StringFormat
|
serialFormat: StringFormat
|
||||||
) = configureReadStandardCrudRepoRoutes(originalRepo) {
|
) = configureReadCRUDRepoRoutes(originalRepo) {
|
||||||
serialFormat.decodeFromString(idsSerializer, it)
|
serialFormat.decodeFromString(idsSerializer, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified ObjectType, reified IdType> Route.configureReadStandardCrudRepoRoutes(
|
inline fun <reified ObjectType, reified IdType> Route.configureReadCRUDRepoRoutes(
|
||||||
originalRepo: ReadStandardCRUDRepo<ObjectType, IdType>,
|
originalRepo: ReadCRUDRepo<ObjectType, IdType>,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: BinaryFormat
|
serialFormat: BinaryFormat
|
||||||
) = configureReadStandardCrudRepoRoutes(originalRepo) {
|
) = configureReadCRUDRepoRoutes(originalRepo) {
|
||||||
serialFormat.decodeHex(idsSerializer, it)
|
serialFormat.decodeHex(idsSerializer, it)
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import dev.inmo.micro_utils.ktor.common.standardKtorSerialFormat
|
|||||||
import dev.inmo.micro_utils.ktor.server.*
|
import dev.inmo.micro_utils.ktor.server.*
|
||||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||||
import dev.inmo.micro_utils.pagination.extractPagination
|
import dev.inmo.micro_utils.pagination.extractPagination
|
||||||
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.countRouting
|
import dev.inmo.micro_utils.repos.ktor.common.countRouting
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
@ -15,8 +15,8 @@ import io.ktor.server.routing.get
|
|||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
fun <ObjectType, IdType> Route.configureReadStandardCrudRepoRoutes(
|
fun <ObjectType, IdType> Route.configureReadCRUDRepoRoutes(
|
||||||
originalRepo: ReadStandardCRUDRepo<ObjectType, IdType>,
|
originalRepo: ReadCRUDRepo<ObjectType, IdType>,
|
||||||
objectsSerializer: KSerializer<ObjectType>,
|
objectsSerializer: KSerializer<ObjectType>,
|
||||||
objectsNullableSerializer: KSerializer<ObjectType?>,
|
objectsNullableSerializer: KSerializer<ObjectType?>,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
@ -73,11 +73,11 @@ fun <ObjectType, IdType> Route.configureReadStandardCrudRepoRoutes(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <ObjectType, IdType> Route.configureReadStandardCrudRepoRoutes(
|
inline fun <ObjectType, IdType> Route.configureReadCRUDRepoRoutes(
|
||||||
originalRepo: ReadStandardCRUDRepo<ObjectType, IdType>,
|
originalRepo: ReadCRUDRepo<ObjectType, IdType>,
|
||||||
objectsSerializer: KSerializer<ObjectType>,
|
objectsSerializer: KSerializer<ObjectType>,
|
||||||
objectsNullableSerializer: KSerializer<ObjectType?>,
|
objectsNullableSerializer: KSerializer<ObjectType?>,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat,
|
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat,
|
||||||
serialFormatContentType: ContentType = standardKtorSerialFormatContentType
|
serialFormatContentType: ContentType = standardKtorSerialFormatContentType
|
||||||
) = configureReadStandardCrudRepoRoutes(originalRepo, objectsSerializer, objectsNullableSerializer, idsSerializer, UnifiedRouter(serialFormat, serialFormatContentType))
|
) = configureReadCRUDRepoRoutes(originalRepo, objectsSerializer, objectsNullableSerializer, idsSerializer, UnifiedRouter(serialFormat, serialFormatContentType))
|
||||||
|
@ -4,15 +4,15 @@ import dev.inmo.micro_utils.ktor.common.StandardKtorSerialFormat
|
|||||||
import dev.inmo.micro_utils.ktor.common.standardKtorSerialFormat
|
import dev.inmo.micro_utils.ktor.common.standardKtorSerialFormat
|
||||||
import dev.inmo.micro_utils.ktor.server.UnifiedRouter
|
import dev.inmo.micro_utils.ktor.server.UnifiedRouter
|
||||||
import dev.inmo.micro_utils.ktor.server.standardKtorSerialFormatContentType
|
import dev.inmo.micro_utils.ktor.server.standardKtorSerialFormatContentType
|
||||||
import dev.inmo.micro_utils.repos.StandardCRUDRepo
|
import dev.inmo.micro_utils.repos.CRUDRepo
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.server.routing.Route
|
import io.ktor.server.routing.Route
|
||||||
import io.ktor.server.routing.route
|
import io.ktor.server.routing.route
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
|
|
||||||
fun <ObjectType, IdType, InputValue> Route.configureStandardCrudRepoRoutes(
|
fun <ObjectType, IdType, InputValue> Route.configureCRUDRepoRoutes(
|
||||||
baseSubpart: String,
|
baseSubpart: String,
|
||||||
originalRepo: StandardCRUDRepo<ObjectType, IdType, InputValue>,
|
originalRepo: CRUDRepo<ObjectType, IdType, InputValue>,
|
||||||
objectsSerializer: KSerializer<ObjectType>,
|
objectsSerializer: KSerializer<ObjectType>,
|
||||||
objectsNullableSerializer: KSerializer<ObjectType?>,
|
objectsNullableSerializer: KSerializer<ObjectType?>,
|
||||||
inputsSerializer: KSerializer<InputValue>,
|
inputsSerializer: KSerializer<InputValue>,
|
||||||
@ -20,20 +20,20 @@ fun <ObjectType, IdType, InputValue> Route.configureStandardCrudRepoRoutes(
|
|||||||
unifiedRouter: UnifiedRouter
|
unifiedRouter: UnifiedRouter
|
||||||
) {
|
) {
|
||||||
route(baseSubpart) {
|
route(baseSubpart) {
|
||||||
configureReadStandardCrudRepoRoutes(originalRepo, objectsSerializer, objectsNullableSerializer, idsSerializer, unifiedRouter)
|
configureReadCRUDRepoRoutes(originalRepo, objectsSerializer, objectsNullableSerializer, idsSerializer, unifiedRouter)
|
||||||
configureWriteStandardCrudRepoRoutes(originalRepo, objectsSerializer, objectsNullableSerializer, inputsSerializer, idsSerializer, unifiedRouter)
|
configureWriteCRUDRepoRoutes(originalRepo, objectsSerializer, objectsNullableSerializer, inputsSerializer, idsSerializer, unifiedRouter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <ObjectType, IdType, InputValue> Route.configureStandardCrudRepoRoutes(
|
fun <ObjectType, IdType, InputValue> Route.configureCRUDRepoRoutes(
|
||||||
baseSubpart: String,
|
baseSubpart: String,
|
||||||
originalRepo: StandardCRUDRepo<ObjectType, IdType, InputValue>,
|
originalRepo: CRUDRepo<ObjectType, IdType, InputValue>,
|
||||||
objectsSerializer: KSerializer<ObjectType>,
|
objectsSerializer: KSerializer<ObjectType>,
|
||||||
objectsNullableSerializer: KSerializer<ObjectType?>,
|
objectsNullableSerializer: KSerializer<ObjectType?>,
|
||||||
inputsSerializer: KSerializer<InputValue>,
|
inputsSerializer: KSerializer<InputValue>,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat,
|
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat,
|
||||||
serialFormatContentType: ContentType = standardKtorSerialFormatContentType
|
serialFormatContentType: ContentType = standardKtorSerialFormatContentType
|
||||||
) = configureStandardCrudRepoRoutes(
|
) = configureCRUDRepoRoutes(
|
||||||
baseSubpart, originalRepo, objectsSerializer, objectsNullableSerializer, inputsSerializer, idsSerializer, UnifiedRouter(serialFormat, serialFormatContentType)
|
baseSubpart, originalRepo, objectsSerializer, objectsNullableSerializer, inputsSerializer, idsSerializer, UnifiedRouter(serialFormat, serialFormatContentType)
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos.ktor.server.crud
|
package dev.inmo.micro_utils.repos.ktor.server.crud
|
||||||
|
|
||||||
import dev.inmo.micro_utils.ktor.server.*
|
import dev.inmo.micro_utils.ktor.server.*
|
||||||
import dev.inmo.micro_utils.repos.WriteStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.WriteCRUDRepo
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
||||||
import io.ktor.server.application.call
|
import io.ktor.server.application.call
|
||||||
import io.ktor.server.request.receive
|
import io.ktor.server.request.receive
|
||||||
@ -9,8 +9,8 @@ import io.ktor.server.response.respond
|
|||||||
import io.ktor.server.routing.Route
|
import io.ktor.server.routing.Route
|
||||||
import io.ktor.server.routing.post
|
import io.ktor.server.routing.post
|
||||||
|
|
||||||
inline fun <reified ObjectType : Any, reified IdType : Any, reified InputValue : Any> Route.configureWriteStandardCrudRepoRoutes(
|
inline fun <reified ObjectType : Any, reified IdType : Any, reified InputValue : Any> Route.configureWriteCRUDRepoRoutes(
|
||||||
originalRepo: WriteStandardCRUDRepo<ObjectType, IdType, InputValue>
|
originalRepo: WriteCRUDRepo<ObjectType, IdType, InputValue>
|
||||||
) {
|
) {
|
||||||
includeWebsocketHandling(
|
includeWebsocketHandling(
|
||||||
newObjectsFlowRouting,
|
newObjectsFlowRouting,
|
@ -3,7 +3,7 @@ package dev.inmo.micro_utils.repos.ktor.server.crud
|
|||||||
import dev.inmo.micro_utils.ktor.common.StandardKtorSerialFormat
|
import dev.inmo.micro_utils.ktor.common.StandardKtorSerialFormat
|
||||||
import dev.inmo.micro_utils.ktor.common.standardKtorSerialFormat
|
import dev.inmo.micro_utils.ktor.common.standardKtorSerialFormat
|
||||||
import dev.inmo.micro_utils.ktor.server.*
|
import dev.inmo.micro_utils.ktor.server.*
|
||||||
import dev.inmo.micro_utils.repos.WriteStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.WriteCRUDRepo
|
||||||
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.server.routing.Route
|
import io.ktor.server.routing.Route
|
||||||
@ -11,8 +11,8 @@ import io.ktor.server.routing.post
|
|||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.*
|
import kotlinx.serialization.builtins.*
|
||||||
|
|
||||||
fun <ObjectType, IdType, InputValue> Route.configureWriteStandardCrudRepoRoutes(
|
fun <ObjectType, IdType, InputValue> Route.configureWriteCRUDRepoRoutes(
|
||||||
originalRepo: WriteStandardCRUDRepo<ObjectType, IdType, InputValue>,
|
originalRepo: WriteCRUDRepo<ObjectType, IdType, InputValue>,
|
||||||
objectsSerializer: KSerializer<ObjectType>,
|
objectsSerializer: KSerializer<ObjectType>,
|
||||||
objectsNullableSerializer: KSerializer<ObjectType?>,
|
objectsNullableSerializer: KSerializer<ObjectType?>,
|
||||||
inputsSerializer: KSerializer<InputValue>,
|
inputsSerializer: KSerializer<InputValue>,
|
||||||
@ -94,14 +94,14 @@ fun <ObjectType, IdType, InputValue> Route.configureWriteStandardCrudRepoRoutes(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <ObjectType, IdType, InputValue> Route.configureWriteStandardCrudRepoRoutes(
|
fun <ObjectType, IdType, InputValue> Route.configureWriteCRUDRepoRoutes(
|
||||||
originalRepo: WriteStandardCRUDRepo<ObjectType, IdType, InputValue>,
|
originalRepo: WriteCRUDRepo<ObjectType, IdType, InputValue>,
|
||||||
objectsSerializer: KSerializer<ObjectType>,
|
objectsSerializer: KSerializer<ObjectType>,
|
||||||
objectsNullableSerializer: KSerializer<ObjectType?>,
|
objectsNullableSerializer: KSerializer<ObjectType?>,
|
||||||
inputsSerializer: KSerializer<InputValue>,
|
inputsSerializer: KSerializer<InputValue>,
|
||||||
idsSerializer: KSerializer<IdType>,
|
idsSerializer: KSerializer<IdType>,
|
||||||
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat,
|
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat,
|
||||||
serialFormatContentType: ContentType = standardKtorSerialFormatContentType
|
serialFormatContentType: ContentType = standardKtorSerialFormatContentType
|
||||||
) = configureWriteStandardCrudRepoRoutes(
|
) = configureWriteCRUDRepoRoutes(
|
||||||
originalRepo, objectsSerializer, objectsNullableSerializer, inputsSerializer, idsSerializer, UnifiedRouter(serialFormat, serialFormatContentType)
|
originalRepo, objectsSerializer, objectsNullableSerializer, inputsSerializer, idsSerializer, UnifiedRouter(serialFormat, serialFormatContentType)
|
||||||
)
|
)
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
package dev.inmo.micro_utils.repos.ktor.server.crud
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.ktor.common.*
|
|
||||||
import dev.inmo.micro_utils.ktor.server.UnifiedRouter
|
|
||||||
import dev.inmo.micro_utils.ktor.server.standardKtorSerialFormatContentType
|
|
||||||
import dev.inmo.micro_utils.repos.StandardCRUDRepo
|
|
||||||
import io.ktor.http.ContentType
|
|
||||||
import io.ktor.server.routing.Route
|
|
||||||
import io.ktor.server.routing.route
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
inline fun <reified ObjectType : Any, reified IdType : Any, reified InputValue : Any> Route.configureStandardCrudRepoRoutes(
|
|
||||||
originalRepo: StandardCRUDRepo<ObjectType, IdType, InputValue>,
|
|
||||||
noinline idDeserializer: suspend (String) -> IdType
|
|
||||||
) {
|
|
||||||
configureReadStandardCrudRepoRoutes(originalRepo, idDeserializer)
|
|
||||||
configureWriteStandardCrudRepoRoutes(originalRepo)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun <reified ObjectType : Any, reified IdType : Any, reified InputValue : Any> Route.configureStandardCrudRepoRoutes(
|
|
||||||
originalRepo: StandardCRUDRepo<ObjectType, IdType, InputValue>,
|
|
||||||
idsSerializer: KSerializer<IdType>,
|
|
||||||
serialFormat: StringFormat
|
|
||||||
) = configureStandardCrudRepoRoutes(originalRepo) {
|
|
||||||
serialFormat.decodeFromString(idsSerializer, it)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun <reified ObjectType : Any, reified IdType : Any, reified InputValue : Any> Route.configureStandardCrudRepoRoutes(
|
|
||||||
originalRepo: StandardCRUDRepo<ObjectType, IdType, InputValue>,
|
|
||||||
idsSerializer: KSerializer<IdType>,
|
|
||||||
serialFormat: BinaryFormat
|
|
||||||
) = configureStandardCrudRepoRoutes(originalRepo) {
|
|
||||||
serialFormat.decodeHex(idsSerializer, it)
|
|
||||||
}
|
|
@ -12,7 +12,7 @@ inline fun <reified Key : Any, reified Value : Any> Route.configureKeyValueRepoR
|
|||||||
noinline valueDeserializer: suspend (String) -> Value
|
noinline valueDeserializer: suspend (String) -> Value
|
||||||
) {
|
) {
|
||||||
configureReadKeyValueRepoRoutes(originalRepo, idDeserializer, valueDeserializer)
|
configureReadKeyValueRepoRoutes(originalRepo, idDeserializer, valueDeserializer)
|
||||||
configureWriteValueRepoRoutes(originalRepo)
|
configureWriteKeyValueRepoRoutes(originalRepo)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified Key : Any, reified Value : Any> Route.configureKeyValueRepoRoutes(
|
inline fun <reified Key : Any, reified Value : Any> Route.configureKeyValueRepoRoutes(
|
@ -26,7 +26,7 @@ fun <K, V> Route.configureKeyValueRepoRoutes(
|
|||||||
valueNullableSerializer,
|
valueNullableSerializer,
|
||||||
unifiedRouter
|
unifiedRouter
|
||||||
)
|
)
|
||||||
configureWriteValueRepoRoutes(
|
configureWriteKeyValueRepoRoutes(
|
||||||
originalRepo,
|
originalRepo,
|
||||||
keySerializer,
|
keySerializer,
|
||||||
valueSerializer,
|
valueSerializer,
|
||||||
|
@ -11,7 +11,7 @@ import io.ktor.server.routing.post
|
|||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.*
|
import kotlinx.serialization.builtins.*
|
||||||
|
|
||||||
fun <K, V> Route.configureWriteValueRepoRoutes (
|
fun <K, V> Route.configureWriteKeyValueRepoRoutes (
|
||||||
originalRepo: WriteKeyValueRepo<K, V>,
|
originalRepo: WriteKeyValueRepo<K, V>,
|
||||||
keySerializer: KSerializer<K>,
|
keySerializer: KSerializer<K>,
|
||||||
valueSerializer: KSerializer<V>,
|
valueSerializer: KSerializer<V>,
|
||||||
@ -67,4 +67,4 @@ fun <K, V> Route.configureWriteStandartKeyValueRepoRoutes (
|
|||||||
valueSerializer: KSerializer<V>,
|
valueSerializer: KSerializer<V>,
|
||||||
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat,
|
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat,
|
||||||
serialFormatContentType: ContentType = standardKtorSerialFormatContentType
|
serialFormatContentType: ContentType = standardKtorSerialFormatContentType
|
||||||
) = configureWriteValueRepoRoutes(originalRepo, keySerializer, valueSerializer, UnifiedRouter(serialFormat, serialFormatContentType))
|
) = configureWriteKeyValueRepoRoutes(originalRepo, keySerializer, valueSerializer, UnifiedRouter(serialFormat, serialFormatContentType))
|
||||||
|
@ -11,7 +11,7 @@ import io.ktor.server.routing.Route
|
|||||||
import io.ktor.server.routing.post
|
import io.ktor.server.routing.post
|
||||||
import io.ktor.util.reflect.typeInfo
|
import io.ktor.util.reflect.typeInfo
|
||||||
|
|
||||||
inline fun <reified Key : Any, reified Value : Any> Route.configureWriteValueRepoRoutes (
|
inline fun <reified Key : Any, reified Value : Any> Route.configureWriteKeyValueRepoRoutes (
|
||||||
originalRepo: WriteKeyValueRepo<Key, Value>
|
originalRepo: WriteKeyValueRepo<Key, Value>
|
||||||
) {
|
) {
|
||||||
includeWebsocketHandling(
|
includeWebsocketHandling(
|
Loading…
Reference in New Issue
Block a user