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 package org.openrs2.archive.web
import com.github.ajalt.clikt.core.CliktCommand 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 com.google.inject.Guice
import org.openrs2.archive.ArchiveModule import org.openrs2.archive.ArchiveModule
import org.openrs2.inject.CloseableInjector import org.openrs2.inject.CloseableInjector
public class WebCommand : CliktCommand(name = "web") { public class WebCommand : CliktCommand(name = "web") {
private val address by option().default("::")
private val port by option().int().default(8080)
override fun run() { override fun run() {
CloseableInjector(Guice.createInjector(ArchiveModule)).use { injector -> CloseableInjector(Guice.createInjector(ArchiveModule)).use { injector ->
val server = injector.getInstance(WebServer::class.java) 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, private val cachesController: CachesController,
@Json private val mapper: ObjectMapper @Json private val mapper: ObjectMapper
) { ) {
public fun start() { public fun start(address: String, port: Int) {
embeddedServer(Netty, port = 8000) { embeddedServer(Netty, host = address, port = port) {
install(ContentNegotiation) { install(ContentNegotiation) {
register(ContentType.Application.Json, JacksonConverter(mapper)) register(ContentType.Application.Json, JacksonConverter(mapper))
} }

Loading…
Cancel
Save