Restructure, beginning of CLI client

This commit is contained in:
2026-08-04 19:11:32 +02:00
parent 2a1487037b
commit a10423b015
36 changed files with 695 additions and 27 deletions
@@ -30,7 +30,8 @@ sealed class ApiRoute<TReq, TRes: Any>(val verb: String, val path: String, val e
open val bodySource = ReqBodySource.BODY
suspend fun extract(body: HttpResponse, meta: Any? = null): Either<ErrorResponse, TRes> = try {
println("Extracting response for $verb $pattern [${body.status.value}] as ${_resType.type.simpleName} (${_resType.kotlinType}${meta?.let { "; meta = $it" } ?: ""})")
if(_printExtraction)
println("Extracting response for $verb $pattern [${body.status.value}] as ${_resType.type.simpleName} (${_resType.kotlinType}${meta?.let { "; meta = $it" } ?: ""})")
if(body.status.isSuccess()) body.body<TRes>(_resType).value()
else body.body<ErrorResponse>().error()
} catch(e: Exception) {
@@ -131,6 +132,10 @@ sealed class ApiRoute<TReq, TRes: Any>(val verb: String, val path: String, val e
}
companion object {
private var _printExtraction = true
fun disablePrinting() { _printExtraction = false }
fun parseUuid(str: String?) = str?.let {
try {
Uuid.parse(it)