|
@@ -19,10 +19,10 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
|
|
|
import org.springframework.web.servlet.resource.PathResourceResolver
|
|
|
+import java.io.File
|
|
|
import java.io.IOException
|
|
|
import java.io.Serializable
|
|
|
import java.net.InetAddress
|
|
|
-import java.nio.charset.StandardCharsets
|
|
|
import java.util.*
|
|
|
import java.util.concurrent.TimeUnit
|
|
|
import javax.servlet.*
|
|
@@ -72,7 +72,7 @@ class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoad
|
|
|
return
|
|
|
} else {
|
|
|
val search = isResourceAvailable(toPath)
|
|
|
- if (search != null && search != "assets/bootstrap.js") {
|
|
|
+ if (search != null && !search.endsWith("assets/bootstrap.js")) {
|
|
|
res.sendRedirect("/resources/$search")
|
|
|
} else {
|
|
|
println("client $client")
|
|
@@ -113,8 +113,8 @@ class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoad
|
|
|
it.entries
|
|
|
.filter { f -> resFromSocket.statusCode < 400 || (resFromSocket.statusCode >= 400 && f.key == "Content-Type") }
|
|
|
.forEach { en ->
|
|
|
- res.setHeader(en.key, en.value.joinToString(","))
|
|
|
- }
|
|
|
+ res.setHeader(en.key, en.value.joinToString(","))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
resFromSocket.body?.let {
|
|
@@ -133,15 +133,14 @@ class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoad
|
|
|
|
|
|
fun isResourceAvailable(path: String, itr: Int = 1): String? {
|
|
|
val splPath = path.split("/").takeLast(itr)
|
|
|
- if (splPath.size >= itr) {
|
|
|
+ val f = File("web")
|
|
|
+ if (splPath.size >= itr && f.isDirectory) {
|
|
|
val search = splPath.joinToString("/")
|
|
|
- println("search $search")
|
|
|
- val resource = resourceLoader.getResource("file:web/$search")
|
|
|
- return if (resource.exists() && resource.file.isFile) {
|
|
|
- return search
|
|
|
- } else {
|
|
|
- isResourceAvailable(path, itr + 1)
|
|
|
- }
|
|
|
+// println("search $search")
|
|
|
+ return f.listFiles()?.filter { it.isDirectory }?.map { it.name }?.map {
|
|
|
+ Pair(it, resourceLoader.getResource("file:web/$it/$search"))
|
|
|
+ }?.filter { it.second.exists() && it.second.file.isFile }?.map { "${it.first}/$search" }?.firstOrNull()
|
|
|
+ ?: isResourceAvailable(path, itr + 1)
|
|
|
}
|
|
|
return null
|
|
|
}
|