Dynamic resource handler with parameter

Viewed 106

In my Spring Boot application, I have a code like this:

registry.addResourceHandler("resources/**").addResourceLocations("file:///" + path) 

in a configuration for mapping a url to a file system address. However, I need two more requirements:

  1. I can have a parameter in the url which I can use to find the appropriate file system path. For example, I can map "projects/1/resources/**" to ("file:///" + path1) and "projects/2/resources/**" to ("file:///" + path2), ...
  2. I can add more mappings dynamically: mappings for projects 2, 3, 4, ...

How can I do that without implementing it myself (defining a rest controller with a parameter, reading the files, returning the file contents, ...)?

0 Answers
Related