Using WebFilter
We will be building on top of our project, spring-boot-webflux. To make it isolated from other projects, we will create a new project, spring-boot-webflux-custom. As indicated previously, using WebFilter applies to both annotation-based and functional-based WebFlux approaches. In our example, we'll have two paths: filtertest1 and filtertest2. We will write test cases using WebFluxTestClient, and will assert certain conditions. Being separate from the rest, we will create a new routing config, a handler, and an entirely new REST controller. We will not go into detail on some of the aspects already covered. In this section, we will just go through the WebFilter code, and also some important aspects of the test cases:
@Component ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access