|
|
@ -1,12 +1,17 @@ |
|
|
|
package org.openrs2.archive.web |
|
|
|
package org.openrs2.archive.web |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper |
|
|
|
import io.ktor.application.call |
|
|
|
import io.ktor.application.call |
|
|
|
import io.ktor.application.install |
|
|
|
import io.ktor.application.install |
|
|
|
|
|
|
|
import io.ktor.features.ContentNegotiation |
|
|
|
|
|
|
|
import io.ktor.http.ContentType |
|
|
|
|
|
|
|
import io.ktor.jackson.JacksonConverter |
|
|
|
import io.ktor.routing.get |
|
|
|
import io.ktor.routing.get |
|
|
|
import io.ktor.routing.routing |
|
|
|
import io.ktor.routing.routing |
|
|
|
import io.ktor.server.engine.embeddedServer |
|
|
|
import io.ktor.server.engine.embeddedServer |
|
|
|
import io.ktor.server.netty.Netty |
|
|
|
import io.ktor.server.netty.Netty |
|
|
|
import io.ktor.thymeleaf.Thymeleaf |
|
|
|
import io.ktor.thymeleaf.Thymeleaf |
|
|
|
|
|
|
|
import org.openrs2.json.Json |
|
|
|
import org.thymeleaf.extras.java8time.dialect.Java8TimeDialect |
|
|
|
import org.thymeleaf.extras.java8time.dialect.Java8TimeDialect |
|
|
|
import org.thymeleaf.templatemode.TemplateMode |
|
|
|
import org.thymeleaf.templatemode.TemplateMode |
|
|
|
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver |
|
|
|
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver |
|
|
@ -16,10 +21,15 @@ import javax.inject.Singleton |
|
|
|
@Singleton |
|
|
|
@Singleton |
|
|
|
public class WebServer @Inject constructor( |
|
|
|
public class WebServer @Inject constructor( |
|
|
|
private val cachesController: CachesController, |
|
|
|
private val cachesController: CachesController, |
|
|
|
private val keysController: KeysController |
|
|
|
private val keysController: KeysController, |
|
|
|
|
|
|
|
@Json private val mapper: ObjectMapper |
|
|
|
) { |
|
|
|
) { |
|
|
|
public fun start() { |
|
|
|
public fun start() { |
|
|
|
embeddedServer(Netty, port = 8000) { |
|
|
|
embeddedServer(Netty, port = 8000) { |
|
|
|
|
|
|
|
install(ContentNegotiation) { |
|
|
|
|
|
|
|
register(ContentType.Application.Json, JacksonConverter(mapper)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
install(Thymeleaf) { |
|
|
|
install(Thymeleaf) { |
|
|
|
addDialect(Java8TimeDialect()) |
|
|
|
addDialect(Java8TimeDialect()) |
|
|
|
|
|
|
|
|
|
|
@ -32,6 +42,7 @@ public class WebServer @Inject constructor( |
|
|
|
routing { |
|
|
|
routing { |
|
|
|
get("/caches") { cachesController.index(call) } |
|
|
|
get("/caches") { cachesController.index(call) } |
|
|
|
get("/caches/{id}.zip") { cachesController.export(call) } |
|
|
|
get("/caches/{id}.zip") { cachesController.export(call) } |
|
|
|
|
|
|
|
get("/caches/{id}.json") { cachesController.exportKeys(call) } |
|
|
|
|
|
|
|
|
|
|
|
// ideally we'd use POST /keys here, but I want to be compatible with the RuneLite/OpenOSRS API |
|
|
|
// ideally we'd use POST /keys here, but I want to be compatible with the RuneLite/OpenOSRS API |
|
|
|
get("/keys/submit") { keysController.create(call) } |
|
|
|
get("/keys/submit") { keysController.create(call) } |
|
|
|