-
Notifications
You must be signed in to change notification settings - Fork 119
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
Add @ConsumseJson to contents API. #999
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #999 +/- ##
============================================
+ Coverage 65.61% 70.88% +5.27%
- Complexity 3319 3933 +614
============================================
Files 355 388 +33
Lines 13865 15661 +1796
Branches 1498 1704 +206
============================================
+ Hits 9098 11102 +2004
+ Misses 3916 3580 -336
- Partials 851 979 +128 ☔ View full report in Codecov by Sentry. |
It looks good.
Would you add a test that verifies the status? It is a simple test but will be helpful to detect regressions in the future. |
@ikhoon nim, i make a new commit to apply your comments. I discovered something in the process. the values may differ! Since the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @chickenchickenlove! 👍👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @chickenchickenlove ❤️
Motivation:
content-type
in header, Central Dogma returns the response: {"exception":"java.lang.IllegalArgumentException","message":"No suitable request converter found for a @RequestObject 'CommitMessageDto'"}
. This response is quite ambiguous, making it difficult for the client to understand the problem.Modifications:
@ConsumesJson
to each method that usesChangesRequestConverter.class
.FYI
@RequestConverter
is declared on method signatures, Armeria will add an object Resolver. (link)ChangesRequestConverter
tries to parse body from request. Actually,ChangeRequestConverter
delegates toJacksonRequestConvertFunction
.JacksonRequestConverter
validates contents type. (here)content-type
orcontent-type
is notapplication/json
,JacksonRequestConverter
will callRequestConverterFunction.fallthrough()
.With this flow, client will receive response
: {"exception":"java.lang.IllegalArgumentException","message":"No suitable request converter found for a @RequestObject 'CommitMessageDto'"}
.If
@ConsumsJson
is delcared to each method havingChangesRequestConverter.class
on their method signature, Armeria will not try to resolve request without headerContent-Type: application/json
.Result:
@Consume(content-type)
to all REST services class or methods #987.