<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
</parent>
@Bean
UndertowServletWebServerFactory embeddedUndertowWebFactory() {
UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory();
FilterInfo filter = new FilterInfo("webProtocolFilter",WebProtocolFilter.class);
factory.addDeploymentInfoCustomizers(deploymentInfo -> deploymentInfo.setUrlEncoding("utf-8").addFilter(filter).addFilterUrlMapping("webProtocolFilter","/*", DispatcherType.REQUEST).addInitialHandlerChainWrapper(handler -> {
PathHandler pathHandler = Handlers.path().addPrefixPath("/", handler);
Map<String, ApiInvocation> apiContainer = facadeProcessor.getApiContainer();
for(Map.Entry<String, ApiInvocation> entry : apiContainer.entrySet()){
String uri = entry.getKey();
ApiInvocation invocation = entry.getValue();
pathHandler.addPrefixPath(uri,new CustHttpHandler(uri,invocation));
}
return pathHandler;
}
));
return factory;
}
request http://localhost:8080/user/address/query the webProtocolFilter not work
Comment From: wilkinsona
A servlet filter will only work when a request is going to be handled by a servlet. Looking at the above, it's not clear that there will be such a servlet available to Undertow. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.