I ran the application and I was able to make REST calls at localhost:8080/resturl. VICTORY!!!
Wait... Not so fast. I need to add v1/ in front resturl for versioning so the call would be like localhost:8080/v1/resturl .
Hmm. For that I needed to register DispatcherServlet and define the mapping:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public DispatcherServlet dispatcherServlet() { | |
return new DispatcherServlet(); | |
} | |
@Bean | |
public ServletRegistrationBean dispatchcherServletRegistration(){ | |
ServletRegistrationBean registrationBean =new ServletRegistrationBean(dispatcherServlet(), "/rest/v1/*"); | |
registrationBean | |
.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME ); | |
return registrationBean; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public CustomFilter customFilter(){ | |
return new CustomFilter(); | |
} | |
@Bean | |
public FilterRegistrationBean customFilterRegistration(){ | |
FilterRegistrationBean customFilterRegistration=new FilterRegistrationBean(metricsFilter(), dispatcherServletRegistration()); | |
return customFilterRegistration; | |
} |
No comments:
Post a Comment