I'm trying rewrite this Google App Engine maven server repository to Spring.
I have problem with URL mapping. Maven repo server standard looks like this:
URL with slash at the end, points to a folder, example:
http://127.0.0.1/testDir/ http://127.0.0.1/testDir/testDir2/
all others (without slash at the end) point to files, example:
http://127.0.0.1/testFile.jar http://127.0.0.1/testFile.jar.sha1 http://127.0.0.1/testDir/testFile2.pom http://127.0.0.1/testDir/testFile2.pom.md5
Original app mapping for directories and for files.
There were used annotations @javax.ws.rs.Path
which supports regexy differently than Spring.
I tried bunch of combinations, for example something like this:
@ResponseBody
@GetMapping("/{file: .*}")
public String test1(@PathVariable String file) {
return "test1 " + file;
}
@ResponseBody
@GetMapping("{dir: .*[/]{1}$}")
public String test2(@PathVariable String dir) {
return "test2 " + dir;
}
But I can't figure out how to do this in right way in Spring application.
I'd like to avoid writing a custom servlet dispatcher.
Try this solution:
Results for URIs from the question: