gateway 如何实现ip hash负载策略

在项目中需要用到ip负载策略,于是搜了一堆资料,实现了自定义的IpHashRule,但是有个问题,在IpHashRule中 老是获取不到request,一直为null
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
也一直没有搜到解决方法,求解决方法
或者说如何实现gateway ip hash负载