Is it possible to control a @RestController
programmatically to enable it or disable it? I don't want to just write code in each @RequestMapping
method to do some kind of if (!enabled) { return 404Exception; }
I've seen this question but that works only at startup time. What I need is really something that would allow me to enable or disable the controller multiple times.
I've thought of different ways but don't know which are doable in spring.
- Actually control the container (jetty in my case) so requests to that particular endpoint are disabled
- Somehow control
RequestMappingHandlerMapping
since it seems to be that class that does the mapping between urls and controllers - control the lifecycle of the
@RestController
component so that i can create it and destroy it at will, but then i'm not sure how to trigger the mapping to the endpoint