libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 4604071f1baa7f8d297295ddccb97b8e3adf1e5a
parent b0e1a2b3cd3eb0ce3c6f6567570f019fe9a36900
Author: MS <ms@taler.net>
Date:   Tue, 19 Sep 2023 14:58:46 +0200

Responding to POST /withdrawals.

Diffstat:
Mbank/src/main/kotlin/tech/libeufin/bank/talerWebHandlers.kt | 5++++-
Mutil/src/main/kotlin/HTTP.kt | 2+-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/talerWebHandlers.kt b/bank/src/main/kotlin/tech/libeufin/bank/talerWebHandlers.kt @@ -29,6 +29,7 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* import net.taler.common.errorcodes.TalerErrorCode +import tech.libeufin.util.getBaseUrl import java.util.* fun Routing.talerWebHandlers() { @@ -65,9 +66,11 @@ fun Routing.talerWebHandlers() { ) throw internalServerError("Bank failed at creating the withdraw operation.") + val bankBaseUrl = call.request.getBaseUrl() + ?: throw internalServerError("Bank could not find its base URL") call.respond(BankAccountCreateWithdrawalResponse( withdrawal_id = opId.toString(), - taler_withdraw_uri = "FIXME" + taler_withdraw_uri = getTalerWithdrawUri(bankBaseUrl, opId.toString()) )) return@post } diff --git a/util/src/main/kotlin/HTTP.kt b/util/src/main/kotlin/HTTP.kt @@ -8,7 +8,7 @@ import io.ktor.server.util.* import io.ktor.util.* import logger -// Get the base URL of a request; handles proxied case. +// Get the base URL of a request, returns null if any problem occurs. fun ApplicationRequest.getBaseUrl(): String? { return if (this.headers.contains("X-Forwarded-Host")) { logger.info("Building X-Forwarded- base URL")