1
0
Fork 1
mirror of https://gitlab.com/mangadex-pub/mangadex_at_home.git synced 2024-01-19 02:48:37 +00:00

Merge branch 'dev_setting' into 'master'

added optional dev-settings

See merge request mangadex-pub/mangadex_at_home!47
This commit is contained in:
carbotaniuman 2020-07-02 16:02:40 +00:00
commit 6b3ca2eee2
2 changed files with 18 additions and 5 deletions

View file

@ -51,7 +51,7 @@ class ServerHandler(private val settings: ClientSettings) {
"secret" to settings.clientSecret "secret" to settings.clientSecret
) )
val request = STRING_ANY_MAP_LENS(params, Request(Method.POST, SERVER_ADDRESS + "stop")) val request = STRING_ANY_MAP_LENS(params, Request(Method.POST, getServerAddress() + "stop"))
val response = client(request) val response = client(request)
return response.status.successful return response.status.successful
@ -83,7 +83,7 @@ class ServerHandler(private val settings: ClientSettings) {
LOGGER.info("Connecting to the control server") LOGGER.info("Connecting to the control server")
} }
val request = STRING_ANY_MAP_LENS(getPingParams(), Request(Method.POST, SERVER_ADDRESS + "ping")) val request = STRING_ANY_MAP_LENS(getPingParams(), Request(Method.POST, getServerAddress() + "ping"))
val response = client(request) val response = client(request)
return if (response.status.successful) { return if (response.status.successful) {
@ -98,7 +98,7 @@ class ServerHandler(private val settings: ClientSettings) {
LOGGER.info("Pinging the control server") LOGGER.info("Pinging the control server")
} }
val request = STRING_ANY_MAP_LENS(getPingParams(old.tls!!.createdAt), Request(Method.POST, SERVER_ADDRESS + "ping")) val request = STRING_ANY_MAP_LENS(getPingParams(old.tls!!.createdAt), Request(Method.POST, getServerAddress() + "ping"))
val response = client(request) val response = client(request)
return if (response.status.successful) { return if (response.status.successful) {
@ -108,11 +108,18 @@ class ServerHandler(private val settings: ClientSettings) {
} }
} }
private fun getServerAddress(): String {
return if (settings.devSettings == null || !settings.devSettings.isDev)
SERVER_ADDRESS
else
SERVER_ADDRESS_DEV
}
companion object { companion object {
private val LOGGER = LoggerFactory.getLogger(ServerHandler::class.java) private val LOGGER = LoggerFactory.getLogger(ServerHandler::class.java)
private val STRING_ANY_MAP_LENS = Body.auto<Map<String, Any>>().toLens() private val STRING_ANY_MAP_LENS = Body.auto<Map<String, Any>>().toLens()
private val SERVER_SETTINGS_LENS = Body.auto<ServerSettings>().toLens() private val SERVER_SETTINGS_LENS = Body.auto<ServerSettings>().toLens()
private const val SERVER_ADDRESS = "https://api.mangadex.network/" private const val SERVER_ADDRESS = "https://api.mangadex.network/"
// private const val SERVER_ADDRESS = "https://mangadex-test.net/" private const val SERVER_ADDRESS_DEV = "https://mangadex-test.net/"
} }
} }

View file

@ -34,7 +34,8 @@ data class ClientSettings(
@field:Secret val clientSecret: String = "PASTE-YOUR-SECRET-HERE", @field:Secret val clientSecret: String = "PASTE-YOUR-SECRET-HERE",
val threads: Int = 4, val threads: Int = 4,
val gracefulShutdownWaitSeconds: Int = 60, val gracefulShutdownWaitSeconds: Int = 60,
val webSettings: WebSettings? = null val webSettings: WebSettings? = null,
val devSettings: DevSettings? = null
) )
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class) @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
@ -42,3 +43,8 @@ data class WebSettings(
val uiHostname: String = "127.0.0.1", val uiHostname: String = "127.0.0.1",
val uiPort: Int = 8080 val uiPort: Int = 8080
) )
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
data class DevSettings(
val isDev: Boolean = false
)