summaryrefslogtreecommitdiff
path: root/nexus/src/main/kotlin/tech/libeufin/nexus/server
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-08-03 14:43:45 +0200
committerFlorian Dold <florian@dold.me>2021-08-03 14:43:45 +0200
commit4bf7300afa7ee9d0b1959833d448618d7dd34b0c (patch)
tree58819f913a27cbe3f6007a587bb9e79c046a7782 /nexus/src/main/kotlin/tech/libeufin/nexus/server
parentc0751302ccd2b6c5af6f6b5240ae0655d45fc533 (diff)
downloadlibeufin-4bf7300afa7ee9d0b1959833d448618d7dd34b0c.tar.gz
libeufin-4bf7300afa7ee9d0b1959833d448618d7dd34b0c.tar.bz2
libeufin-4bf7300afa7ee9d0b1959833d448618d7dd34b0c.zip
fix facade URL creation
Diffstat (limited to 'nexus/src/main/kotlin/tech/libeufin/nexus/server')
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt32
1 files changed, 12 insertions, 20 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index 9b53c4bf..b8c7404c 100644
--- 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)
)
)