Add MethodInterceptor extension point with feign-validation and feign-http-cache modules#3346
Merged
Conversation
…-http-cache modules Signed-off-by: Marvin Froeder <velo.br@gmail.com>
Signed-off-by: Marvin Froeder <velo.br@gmail.com>
Signed-off-by: Marvin Froeder <velo.br@gmail.com>
Signed-off-by: Marvin Froeder <velo.br@gmail.com>
…re regex, annotation cache) Signed-off-by: Marvin Froeder <velo.br@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
feign.MethodInterceptorextension point: an around-style interceptor that wraps the entire HTTP exchange afterContractresolution. It has access to raw method arguments,MethodMetadata, the resolvedRequestTemplate, and (afterchain.next()completes) the capturedResponse. Marked@Experimental.feign-validationandfeign-validation-jakartamodules:BeanValidationMethodInterceptorruns JSR-303 / Jakarta Bean Validation against the body argument and any@Valid-annotated parameters before the request is dispatched. Constraint violations surface asConstraintViolationException.feign-http-cachemodule:HttpCacheInterceptoradds conditionalIf-None-Match/If-Modified-Sinceheaders, stores 2xx responses withETag/Last-Modifiedvalidators, and short-circuits to the cached value on304 Not Modified. PluggableHttpCacheStoreSPI plus anInMemoryHttpCacheStoredefault.Why
RequestInterceptoronly sees the encodedRequestTemplate;ResponseInterceptoronly sees the response. Use cases like body validation (needs the typed object before encoding) and HTTP cache (needs both the request and the response, and may short-circuit) needed a third extension point. The two new modules ship as flagship implementations.Test plan
mvn -Pdev clean install -DskipITs(full reactor, 54 modules, all green)core/src/test/java/feign/MethodInterceptorTest.javacovers chain order, short-circuit, exception propagation, andInvocation.response()visibility.@Validon non-body parameters honoured, no-arg methods pass through.Cache-Control: no-storeskipped, 5xx propagates without evicting.