libeufin

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

commit 83c7d6e3834cbec410e7596a58d7104184c5814e
parent d7dc764e1c19022a5d1fd3a73c02096c3cd75af4
Author: Florian Dold <florian.dold@gmail.com>
Date:   Sun, 21 Jun 2020 17:35:03 +0530

allow to specify listen host, default to localhost

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 11++++++++++-
Mnexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt | 4++--
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -21,11 +21,14 @@ package tech.libeufin.nexus import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.ProgramResult +import com.github.ajalt.clikt.core.context import com.github.ajalt.clikt.core.subcommands +import com.github.ajalt.clikt.output.CliktHelpFormatter import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.options.default import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.prompt +import com.github.ajalt.clikt.parameters.types.int import org.jetbrains.exposed.sql.transactions.transaction import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -39,9 +42,15 @@ class NexusCommand : CliktCommand() { } class Serve : CliktCommand("Run nexus HTTP server") { + init { + context { + helpFormatter = CliktHelpFormatter(showDefaultValues = true) + } + } private val dbName by option().default("libeufin-nexus.sqlite3") + private val host by option().default("127.0.0.1") override fun run() { - serverMain(dbName) + serverMain(dbName, host) } } diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt @@ -192,12 +192,12 @@ fun requireBankConnection(call: ApplicationCall, parameterKey: String): NexusBan } -fun serverMain(dbName: String) { +fun serverMain(dbName: String, host: String) { dbCreateTables(dbName) val client = HttpClient { expectSuccess = false // this way, it does not throw exceptions on != 200 responses. } - val server = embeddedServer(Netty, port = 5001) { + val server = embeddedServer(Netty, port = 5001, host = host) { install(CallLogging) { this.level = Level.DEBUG this.logger = tech.libeufin.nexus.logger