Is it possible for springboot/spring-mvc or Jersey to add controller (& methods) at runtime ?
Meaning when running , user may input a controller name ( such as user
) , and method name sayHello
, and submit , and /user/sayHello/
is enabled without restarting spring server ?
(As to what to response , that's beyond the scope , just assume reply 'OK' )
If spring cannot achieve it , which JVM rest framework supports such functionality ?
It seems jersey can Programmatically build API Resource , but how about runtime ?
You could achieve this result by using URI templates in your request mapping. Assuming the number of variations is finite and you can abstract your request mappings to the least amount required.
The above example would catch your "/user/sayHello" request, or any other request which contains 2 parts in the path. If you have some more complex variations, you could create request mappings accordingly.
It's not posible to register new route in the Dispatcher Servlet after the load of the application context.
You can create a controller method to "catch" a variety of requests with a wildcard
and then route the request manually in the method body.