Backend Fixes...

This commit is contained in:
2024-11-26 16:34:24 +01:00
parent df37fa1564
commit d5c06688f0
2 changed files with 4 additions and 3 deletions
@@ -29,6 +29,7 @@ import io.ktor.server.application.hooks.*
import io.ktor.server.auth.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.util.*
data class SWAuthPrincipal(val token: Token, val user: SteamwarUser) : Principal
@@ -104,7 +105,7 @@ Message: ${cause.message}
}
onCallRespond { call ->
if (call.response.status()?.isSuccess() == true) {
if ((call.response.status() ?: HttpStatusCode.OK).isSuccess()) {
return@onCallRespond
}
@@ -120,7 +121,7 @@ Message: ${cause.message}
Headers:
${call.request.headers.entries().joinToString("\n ") { "${it.key}: ${it.value}" }}
Body:
${call.request.receiveChannel()}
${call.request.receiveChannel().toByteArray().decodeToString()}
""".trimIndent()
SWException.log(msg, stack)
@@ -50,7 +50,7 @@ fun Application.configurePlugins() {
it.request.headers["X-Forwarded-For"] ?: it.request.local.remoteHost
}
requestWeight { applicationCall, _ ->
if(applicationCall.request.headers["X-Forwarded-For"] != null) {
if(!applicationCall.request.headers.contains("X-Forwarded-For")) {
0
} else {
1