Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Servlet Filter doesn't seem to work in Dropwizard

I have written a filter called RequestFilter (implements Filter interface) to get HTTP headers of each request. And I added this filter using the following code in Dropwizard run function.

environment.servlets().addFilter("RequestFilter", new RequestFilter());

doFilter doesn't get called on sending a request.

Any hints on why it is not working?

like image 987
Naresh Avatar asked Nov 26 '25 07:11

Naresh


1 Answers

Resolved this issue by adding the following in dropwizard run function.

environment.servlets().addFilter("RequestFilter", new RequestFilter()).addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "<resource_path>/*"); 
like image 137
Naresh Avatar answered Nov 28 '25 22:11

Naresh