'Spring Boot | Aspects | getting ServerHttpRequest | Recaptcha

I am creating a recaptcha on server side.

I would like to work with spring / aspects.

I created an annotation like this:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface RequiresCaptcha {
}

in such a way that I need to get ServerHttpRequest in class that is the implementation of aspect.

@Component
public class CaptchaAop {
    @Autowired
    ValidateCaptcha service;

    @Around("@annotation(com.app.aop.RequiresCaptcha)")
    public Object validateCaptchaResponse(final ProceedingJoinPoint point) {
        // I need get a ServerHttpRequest to call the captcha service to validate recaptcha
    }
}

In spring web mvc, I think that is:

HttpServletRequest request =
                ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();

Working with webflux, how to get ServerHttpRequest in this situation?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source