leonhardt
06/30/2025, 4:02 AMsinglePageApp
helper be used on a subpath? When it's configured on the root path, it works as expected. But when it's configured on a subpath, it still seems to match any path, even ones outside the subpath.leonhardt
06/30/2025, 4:02 AMimport org.http4k.core.Method
import org.http4k.core.Response
import org.http4k.core.Status
import org.http4k.routing.ResourceLoader
import org.http4k.routing.bind
import org.http4k.routing.routes
import org.http4k.routing.singlePageApp
import org.http4k.server.Netty
import org.http4k.server.asServer
fun main() {
println("running example")
val handler = routes(
"/api" bind Method.GET to { Response(Status.OK).body("Hello World!") },
"/spa" bind singlePageApp(ResourceLoader.Classpath("example")),
)
handler.asServer(Netty(port = 8080)).start()
}
The singlePageApp
matches /spa as well as anything else like /testdave
07/01/2025, 2:00 PMleonhardt
07/02/2025, 1:56 AMleonhardt
07/02/2025, 2:43 PMstatic
helper for the files that exist and manually declare the index.html
fallback like so:
val handler = routes(
// "/spa" bind singlePageApp(ResourceLoader.Classpath("example")),
"/spa" bind static(ResourceLoader.Classpath("example")),
"/spa/{path:.*}" bind { static(ResourceLoader.Classpath("example"))(Request(Method.GET, "index.html")) }
)
leonhardt
07/02/2025, 3:47 PMs4nchez
07/06/2025, 6:40 PMwould it help tremendously if I made a PR with a failing testIf that can be reproduced there, that'd be great! Otherwise, please provide some examples of files in the classpath that shouldn't be matched in the example here.
leonhardt
07/06/2025, 7:03 PMleonhardt
07/06/2025, 7:22 PMs4nchez
07/07/2025, 5:58 AM