Add address and port options to WebCommand

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 23bb1ef13c
commit 7fdbe5113f
  1. 8
      archive/src/main/kotlin/org/openrs2/archive/web/WebCommand.kt
  2. 4
      archive/src/main/kotlin/org/openrs2/archive/web/WebServer.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)
}
}
}

@ -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))
}

Loading…
Cancel
Save