Restructure, beginning of CLI client
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user