英文:
Prefix all endpoints with "/api" or another prefix, in spring reactive web (webflux)
问题
我在一个Spring响应式Web项目中有一组RestControllers,并且我想在不同的环境中为所有控制器添加前缀“api”或“test-api”。
我尝试使用server.servlet.context-path=/api
,但在运行在Netty服务器上的Spring响应式Web(Webflux)中不起作用。
英文:
I have a set of RestControllers in a spring reactive web project and I want to prefix all of the controllers with "api" or "test-api" in different environments.
I have tried to use server.servlet.context-path=/api
and it's not working with spring reactive web (webflux) running on Netty server
答案1
得分: 6
以下属性在Spring Boot 2.3中被添加,用于在WebFlux中实现此功能:
spring.webflux.base-path
发布说明:https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#configurable-base-path-for-webflux-applications
英文:
The following property was added in spring boot 2.3 to achieve this with webflux
spring.webflux.base-path
Release Notes: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#configurable-base-path-for-webflux-applications
答案2
得分: 2
你尝试过在 @RequestMapping 中使用占位符,例如 @RequestMapping("${foo.bar}") 吗?
谢谢
英文:
Have you tried using a placeholders in @RequestMapping, like for example @RequestMapping("${foo.bar}") ?
Thank you
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论