Mercury: verify handshake echo, autolock endpoint, ringInfo-safe status

This commit is contained in:
2026-08-25 00:54:31 +03:00
parent b40e44c653
commit 4556d3b6e4
2 changed files with 85 additions and 22 deletions
@@ -61,7 +61,11 @@ object DebugHttpServer {
val parts = requestLine.split(" ")
if (parts.size < 2) return
val method = parts[0]
val path = parts[1]
val rawPath = parts[1]
val path = rawPath.substringBefore("?")
val queryParams = rawPath.substringAfter("?", "").split("&")
.filter { it.isNotEmpty() }
.associate { it.substringBefore("=") to it.substringAfter("=") }
// Тело (до Content-Length)
var contentLength = 0
@@ -141,6 +145,12 @@ object DebugHttpServer {
response = """{"ok":$ok,"status":${jsonEscape(MercuryBridge.state.value.statusText)}}"""
code = 200
}
method == "POST" && path.startsWith("/mercury/autolock") -> {
val time = queryParams["time"]?.toIntOrNull() ?: 10
val ok = kotlinx.coroutines.runBlocking { MercuryBridge.autoLockTime(time) }
response = """{"ok":$ok,"status":${jsonEscape(MercuryBridge.state.value.statusText)}}"""
code = 200
}
else -> {
response = """{"error":"нет такого пути: $method $path"}"""
code = 404