I want to give my routes a prefix based on the folder in which they're in. For example, with this folder structure:
controllers/
├─ v1/
│ ├─ Controller.kt
├─ v2/
│ ├─ Controller.kt
I would like to get the following routes:
{host}/v1/{route}
{host}/v2/{route}
Currently, I need to set the 'prefix' on every controller separately:
@RestController
@RequestMapping("/v2/route")
Is there any way to achieve this in Spring with either custom annotations that allow a prefix (@RestControllerV1("/route")
), or with some setting that just prefixes all files within a specific folder?