-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interface level header defaults #184
Comments
Hi, Jeff.
Good ideas. One thing I was thinking about was if annotation is the best
way for this. Reason being is that it is as you mention a pretty common
act. Could RequestInterceptor be a more composable way to accomplish this?
I understand the downside is that RequestInterceptor isn't visible in the
interface..
…-A
|
ex. if we baked in a simple default request interceptor which set
accept/content-type based on the method (or not)
https://github.com/Netflix/feign/blob/master/core/src/test/java/feign/FeignBuilderTest.java#L99
|
yeah, that's good too. How would you set the media type for that interceptor?
or like
or did you have something else in mind? |
I want to be careful about adding too much to the builder. How about
something like..
Feign.builder().requestInterceptor(AddMediaTypeHeaders.APPLICATION_JSON)
which is a constant.. or heck you could even make the thing an enum :)
at any rate, should be easy to apply json and xml
|
changed the Headers to be able to be on a type. Some of the naming may need to be tweaked to match Feign conventions..
I linked to a commit ^ - before i spend too much more time i wanted to see if this was more inline.. (i'm sure some naming might need tweaking) |
Looks good! One nit would be to adjust the javadoc on Headers to suggest that they are additive, so don't place anything on the type that isn't meant for all methods. That and a test case that shows this. (ex. adding the same header twice = 2 values). Good job, Jeff! |
oof.. @jdamick we have a hitch. My intention is that 8.x is feature compatible with 7.x. That way, folks can migrate cleanly off dagger via the 7-8 bridge. Also, Spring implement Contract. We probably want to avoid changing the Contract interface as a part of this change. What that means is that we'd need some logic to reach up to the type in Headers fromType = method.getDeclaringClass().getAnnotation(Headers.class); Ack that is more expensive than your approach. Wdyt about saving Contract interface refactors for when we bang our heads around hystrix/rxnetty? |
I have no burning need for it at the moment, so i'm fine with waiting until 9. |
This supports interface-level defaults, such as Content-Type. closes #184
This supports interface-level defaults, such as Content-Type. closes #184
This supports interface-level defaults, such as Content-Type. closes #184
added to 7.4/8.1 release after realizing a simple way to accomplish this portably. |
This supports interface-level defaults, such as Content-Type. closes #184
I implemented an enhanced contract that extends the default contract but adds the ability to set interface level Headers as defaults unless overridden at the method level..
I also added convenience annotations for ContentType & Accept since those (at least in our experience) are most typically set.
The annotations follow more of the jaxrs style, but another option I could see would be adding these as settables in the Feign.Builder when creating the client.. I'm on fence as which one i like better.
Are either of these of interest as a pull? @adriancole
The text was updated successfully, but these errors were encountered: