From 7fdbe5113f5167a597655684b27a8399f94c1211 Mon Sep 17 00:00:00 2001 From: Graham Date: Wed, 24 Feb 2021 17:46:54 +0000 Subject: [PATCH] Add address and port options to WebCommand Signed-off-by: Graham --- .../src/main/kotlin/org/openrs2/archive/web/WebCommand.kt | 8 +++++++- .../src/main/kotlin/org/openrs2/archive/web/WebServer.kt | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/archive/src/main/kotlin/org/openrs2/archive/web/WebCommand.kt b/archive/src/main/kotlin/org/openrs2/archive/web/WebCommand.kt index 1ab5cdd700..7951febdf3 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/web/WebCommand.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/web/WebCommand.kt @@ -1,15 +1,21 @@ package org.openrs2.archive.web import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.parameters.options.default +import com.github.ajalt.clikt.parameters.options.option +import com.github.ajalt.clikt.parameters.types.int import com.google.inject.Guice import org.openrs2.archive.ArchiveModule import org.openrs2.inject.CloseableInjector public class WebCommand : CliktCommand(name = "web") { + private val address by option().default("::") + private val port by option().int().default(8080) + override fun run() { CloseableInjector(Guice.createInjector(ArchiveModule)).use { injector -> val server = injector.getInstance(WebServer::class.java) - server.start() + server.start(address, port) } } } diff --git a/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt b/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt index 60f85939bd..a9953d129f 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt @@ -24,8 +24,8 @@ public class WebServer @Inject constructor( private val cachesController: CachesController, @Json private val mapper: ObjectMapper ) { - public fun start() { - embeddedServer(Netty, port = 8000) { + public fun start(address: String, port: Int) { + embeddedServer(Netty, host = address, port = port) { install(ContentNegotiation) { register(ContentType.Application.Json, JacksonConverter(mapper)) }