Reputation: 3128
I'm currently working with Telegram bots and seem like some telegram bots could be served at one endpoint due to lack of information in bot's message to separate one bot's message from another one. New bots can appear during runtime, so I can not hardcode some separate endpoints for every bot. So there is it possible to create a new endpoint by template in spring boot in runtime?
Upvotes: 7
Views: 5797
Reputation: 22496
No. The DispatcherServlet is initialized in an ApplicationContext thats a child context of your root context, so you can't access it.
One way to have a "dynamic" endpoint is to use wildcards in the Request mapping.
@RequestMapping(value="/results/**", method=RequestMethod.GET)
public SomeResult handleResults(HttpServletRequest request) {
String path = request. getRequestURI();
if("asd".equals(path)){...}
}
Upvotes: 15