libeufin

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

commit 4bf7300afa7ee9d0b1959833d448618d7dd34b0c
parent c0751302ccd2b6c5af6f6b5240ae0655d45fc533
Author: Florian Dold <florian@dold.me>
Date:   Tue,  3 Aug 2021 14:43:45 +0200

fix facade URL creation

Diffstat:
Mdebian/changelog | 6++++++
Mnexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt | 32++++++++++++--------------------
2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/debian/changelog b/debian/changelog @@ -1,3 +1,9 @@ +libeufin (0.0.1-5) unstable; urgency=medium + + * Fix facade URL. + + -- Florian Dold <florian@dold.me> Tue, 03 Aug 2021 14:43:33 +0200 + libeufin (0.0.1-4) unstable; urgency=medium * Bugfixes in libeufin-cli and libeufin-nexus. diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt @@ -40,6 +40,7 @@ import io.ktor.response.* import io.ktor.routing.* import io.ktor.server.engine.* import io.ktor.server.netty.* +import io.ktor.util.* import org.jetbrains.exposed.exceptions.ExposedSQLException import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.transactions.transaction @@ -145,24 +146,6 @@ suspend inline fun <reified T : Any> ApplicationCall.receiveJson(): T { } } - -fun createLoopbackBankConnection(bankConnectionName: String, user: NexusUserEntity, data: JsonNode) { - val bankConn = NexusBankConnectionEntity.new { - this.connectionId = bankConnectionName - owner = user - type = "loopback" - } - val bankAccount = jacksonObjectMapper().treeToValue(data, BankAccount::class.java) - NexusBankAccountEntity.new { - bankAccountName = bankAccount.nexusBankAccountId - iban = bankAccount.iban - bankCode = bankAccount.bic - accountHolder = bankAccount.ownerName - defaultBankConnection = bankConn - highestSeenBankMessageSerialId = 0 - } -} - fun requireBankConnectionInternal(connId: String): NexusBankConnectionEntity { return transaction { NexusBankConnectionEntity.find { NexusBankConnectionsTable.connectionId eq connId }.firstOrNull() @@ -865,10 +848,15 @@ fun serverMain(dbName: String, host: String, port: Int) { val f = FacadeEntity.findByName(fcid) ?: throw NexusError( HttpStatusCode.NotFound, "Facade $fcid does not exist" ) + // FIXME: this only works for TWG urls. FacadeShowInfo( name = f.facadeName, type = f.type, - baseUrl = "http://${host}/facades/${f.id.value}/${f.type}/", + twgBaseUrl = call.url { + parameters.clear() + encodedPath = "" + pathComponents("facades", f.facadeName, f.type) + }, config = getFacadeState(f.type, f) ) } @@ -890,7 +878,11 @@ fun serverMain(dbName: String, host: String, port: Int) { FacadeShowInfo( name = it.facadeName, type = it.type, - twgBaseUrl = "http://${host}/facades/${it.facadeName}/${it.type}/", + twgBaseUrl = call.url { + parameters.clear() + encodedPath = "" + pathComponents("facades", it.facadeName, it.type) + }, config = getFacadeState(it.type, it) ) )