In webflux, What is the difference between WebFilter and HandlerFilterFunction

Viewed 834

In spring webflux, What is the difference between WebFilter and HandlerFilterFunction ?

And how i can create a filter that is used for a certain URI ?

1 Answers

The main difference between them is that WebFilter implementations work for all endpoints and HandlerFilterFunction implementations will only work for Router-based ones.

So if you use Router based endpoints you can use either of them. But if you use annotation based (like @RequestMapping/@GetMapping) you can only make use of WebFilter.

Related