Skip to content

Instantly share code, notes, and snippets.

View alabotski's full-sized avatar

Aliaksei L alabotski

View GitHub Profile
@alabotski
alabotski / WebFilterWithRequestCache
Created November 3, 2022 09:45
Just an example. How to get value from RequestBody in WebFilter in WebFlux reactive application and put it in request attributes.
@Order
@Slf4j
@Component
@RequiredArgsConstructor
public class PrepareHeaderWebFilter implements WebFilter {
private static final byte[] EMPTY_BYTES = {};
public static final String CACHED_REQUEST_BODY_ATTR = "cachedRequestBody";
public static final String CACHED_SERVER_HTTP_REQUEST_DECORATOR_ATTR = "cachedServerHttpRequestDecorator";
private static final List<HttpMessageReader<?>> MESSAGE_READERS = HandlerStrategies.withDefaults()