I would like to add or delete Spring Cloud Gateway routes at runtime while the server is running. I'm using the Fluent Java Routes API to initialize gateway routes. This is working perfectly.
However, now I'd like to modify, add, and delete routes while the Spring Cloud Gateway server is running. I can see that the RouteLocator contains my routes, but I see no methods to modify its contents.
Even though I see some ability to create new routes in the actuator, I need to use add them using Java code instead of REST calls. In my setup the RouteDefinitionRepository is empty, so I didn't see any way to use this in my use case.
Is it possible to modify routes at runtime using just Java code in Spring Cloud Gateway?
Use Spring Integration instead. You can use the Java DSL to register and delete Integration Flows. https://docs.spring.io/spring-integration/docs/5.3.2.RELEASE/reference/html/dsl.html#java-dsl-runtime-flows