[F] Wacca: Fix handle

This commit is contained in:
Azalea
2024-03-28 19:08:59 -04:00
parent 2682165da8
commit 4ebddf78ed

View File

@@ -60,7 +60,8 @@ class WaccaServer(val rp: WaccaRepos, val cardRepo: CardRepository) {
/** Handle all requests */ /** Handle all requests */
@API("/api/**") @API("/api/**")
fun handle(req: HttpServletRequest, @RB body: String) = try { fun handle(req: HttpServletRequest, @RB body: String): Any {
return try {
val path = req.requestURI.removePrefix("/g/wacca").removePrefix("/api").removePrefix("/").lowercase() val path = req.requestURI.removePrefix("/g/wacca").removePrefix("/api").removePrefix("/").lowercase()
if (path in cacheMap) return resp(cacheMap[path]!!) if (path in cacheMap) return resp(cacheMap[path]!!)
if (path !in handlerMap) return resp("[]", 1, "Not Found") if (path !in handlerMap) return resp("[]", 1, "Not Found")
@@ -80,6 +81,7 @@ class WaccaServer(val rp: WaccaRepos, val cardRepo: CardRepository) {
resp("[]", 500, e.message ?: "") resp("[]", 500, e.message ?: "")
} }
} }
}
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun WaccaServer.init() { fun WaccaServer.init() {