feat: add a built-in browser test client

- serve a single-page client at /ui (and redirect / to it)
- login, folder switch, album grid, album songs, search and streaming
- enabled by default, disable with WEB_UI=false
- document the test client and WEB_UI
This commit is contained in:
TapTap committed 2026-11-13 12:45:41 +00:00
1 parent 1571ec65ff
commit 26d31834a5
5 files changed
+334 -1

No files matched your search

@@ -1,5 +1,6 @@
package win.taptap.musicmanager
import io.ktor.http.ContentType
import io.ktor.http.HttpStatusCode
import io.ktor.serialization.kotlinx.json.json
import io.ktor.server.application.install
@@ -11,6 +12,7 @@ import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.ktor.server.plugins.partialcontent.PartialContent
import io.ktor.server.plugins.statuspages.StatusPages
import io.ktor.server.request.path
import io.ktor.server.response.respondRedirect
import io.ktor.server.response.respondText
import io.ktor.server.routing.get
import io.ktor.server.routing.routing
@@ -53,6 +55,12 @@ fun main() {
scanner.start(applicationScope)
}
val webUiHtml = if (config.webUiEnabled) {
AppConfig::class.java.getResource("/web/index.html")?.readText()
} else {
null
}
val server = embeddedServer(Netty, port = config.port, host = "0.0.0.0") {
install(ContentNegotiation) {
json(
@@ -79,6 +87,10 @@ fun main() {
routing {
get("/health") { call.respondText("ok") }
if (webUiHtml != null) {
get("/") { call.respondRedirect("/ui") }
get("/ui") { call.respondText(webUiHtml, ContentType.Text.Html) }
}
subsonicRoutes(
users = users,
library = library,