Mercury: verify handshake echo, autolock endpoint, ringInfo-safe status
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user