NextGen APIs

Remove default step

🚫 Please don’t do that!

Removing a default logic is to be considered one of the possible customizations, but if you decide to completely remove a default logic, why not use a completely new API that identifies the required custom behavior?

Anyway, the guide provides for it, so let's see how to do it best, starting from the following implementation example:

Screenshot 2025-02-18 alle 11.00.24.png

Shopping list:

  1. Create a New Custom class AccountGetCustom which implements the legacy Component’s interface AccountGet

    1. The new custom class must be annotated with @Primary annotation, otherwise the custom logic will not be executed before the default one

    2. The new custom class must be annotated with @Component annotation so that it will actually have to take care of executing all the logic associated with the customized use case

    3. The new custom class is annotated with @RequiredArgsConstructor annotation to generate the constructor to initialize the final members of the class

  2. Insert the custom logic in the Component’s overridden method and build the new response completely overwriting the response that would have been obtained by using the legacy component AccountGetImpl: the object built in totally custom mode must be returned wrapped inside a Mono and the simplest way to do this is by using Mono.just(), which creates and returns a Mono of the object passed in input.