-
Notifications
You must be signed in to change notification settings - Fork 26
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
Relax Codable Router type requirements #18
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18 +/- ##
====================================
Coverage 82% 82%
====================================
Files 6 6
Lines 489 489
====================================
Hits 401 401
Misses 88 88
Continue to review full report at Codecov.
|
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.
LGTM.
This is not quite ready. Although this is now correctly typed, there is currently no way for a user to We need to have a think about how the API should permit this, which may require an additional closure type to be defined - such as allowing just an |
Kitura/Kitura@d8ebc69 relaxes the requirements for the Codable router result handler to permit a If this is deemed acceptable, then this PR is ready to go. |
IBM-Swift/evolution#11 has been reviewed and approved. |
Description
Implementation of Kitura Evolution proposal: Relax Type Constraints for Codable Routing
Resolves Kitura/Kitura#1235 by relaxing the type requirements on the Codable Router to Decodable for input types, and Encodable for output types.
This enables a corresponding Pull Request in Kitura: Kitura/Kitura#1242
As this is merely a relaxing of type constraints, it can be delivered in a patch.
Motivation and Context
See Kitura/Kitura#1235.
The Codable Router was designed with a symmetry in mind for types to be shared between the client and server side (KituraKit <-> Kitura), which requires those types to be both Encodable and Decodable.
In addition, for types that contain purely Codable attributes, conformance to Codable can be synthesized by the compiler. However, there are cases where conformance must be implemented manually.
For cases where the user only wants to use type safety in a single direction (such as Decodable for a type that will only be received), we currently require them to implement conformance to Encodable (at least dummy conformance to satisfy the type requirement).
How Has This Been Tested?
Tests have been added to Kitura in Kitura/Kitura#1242 that are dependent on these changes, and those tests are passing.
Checklist: