File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
main/kotlin/net/ccbluex/netty/http/rest Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,10 @@ class RouteController : Node("") {
9696 }
9797
9898 return if (currentNode.matchesMethod(method)) {
99- Destination (currentNode, params, pathArray.joinToString(" /" ))
99+ // remainingPath should only include the unmatched trailing segments,
100+ // not the already matched route path
101+ val remaining = if (index >= pathArray.size) " " else pathArray.copyOfRange(index, pathArray.size).joinToString(" /" )
102+ Destination (currentNode, params, remaining)
100103 } else {
101104 null
102105 }
Original file line number Diff line number Diff line change @@ -90,7 +90,8 @@ class HttpServerTest {
9090 get(" /api/v1/s" , ::static)
9191
9292 get(" /" , ::static)
93- file(" /" , folder)
93+ file(" /abc" , folder)
94+ file(" /def/abc" , folder)
9495 }
9596
9697 server.start(8080 ) // Start the server on port 8080
@@ -300,10 +301,15 @@ class HttpServerTest {
300301
301302 @Test
302303 fun testFileEndpoint () {
304+ testFileEndpoint(" /abc" )
305+ testFileEndpoint(" /def/abc" )
306+ }
307+
308+ fun testFileEndpoint (prefix : String ) {
303309 val files = folder.list() ? : emptyArray()
304310
305311 files.forEach { file ->
306- val response = makeRequest(" /$file " )
312+ val response = makeRequest(" $prefix /$file " )
307313 assertEquals(200 , response.code(), " Expected status code 200 for $file " )
308314
309315 val responseBody = response.body()?.string()
You can’t perform that action at this time.
0 commit comments