-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Feature Request] Custom Type conversion #754
Comments
Thanks for raising this issue! I like this idea. I think the problem is specific to path and query parameters like this one. Can you confirm whether this works when using a POST where the ID is in the body? I'm not sure how we would tell the query/path resolver where to look for decoding. Any ideas? |
1. I need to test the POST, but it doesn’t likely to be problematic imo.
2. I suggest to check for the gogo’s custom type and to use the MarshalJSON
and Unmarshal json funcs as specified here as “convertFunc”
https://github.com/gogo/protobuf/blob/master/custom_types.md
On Thu, 13 Sep 2018 at 0:05 Johan Brandhorst ***@***.***> wrote:
Thanks for raising this issue! I like this idea. I think the problem is
specific to path and query parameters like this one. Can you confirm
whether this works when using a POST where the ID is in the body?
I'm not sure how we would tell the query/path resolver where to look for
decoding. Any ideas?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#754 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGCpoP-T79_RmfMB53nS3qN31rYR0qqks5uaXctgaJpZM4Wl33t>
.
--
<http://www.rimoto.net/>
www.rimoto.com <http://www.rimoto.net/>
*Almog Baku*
*CTO & Cofounder *
Mobile: +972.50.2288.744
Social: * <http://www.facebook.com/AlmogBaku>
<http://www.linkedin.com/in/almogbaku>*
|
Is there anything I can do to help you get a PR for this going? |
gRPC and proto3 are language neutral. The mechanical conversion between JSON and proto3 are defined by proto3 spec. The custom type seems to be a Go-specific feature. Such custom conversion exists in many systems, such as Apigee, but such logic can be endless and very hard to maintain. You also need to update OpenAPI generator, documentation generator, and other tools to support these features. I think it is generally better to handle the conversion in the backend, i.e., creating a separate gRPC method without custom type, the backend converts between method without custom type and method with custom type. The gRPC Gateway just handle the method without custom type. Without this approach, we can handle arbitrary custom types and the backend using the feature carries the burden. The rest of gRPC tooling doesn't need to know anything about it. |
@johanbrandhorst I have faced with the similar issue. Maybe over the time you have some thoughts about it? |
I think @wora made good points about this feature request. We certainly cannot include type checks for any gogoproto types. I am going to close this feature request as rejected. |
This feature is mentioned in the changelog. Should probably be removed? |
The changelog is generated so changing it manually will just be reset next time we generate it. I'll update the release notes though. |
Adding a future to add custom types(especially to support "gogo's custom type" can be very useful.
In my scenario:
As you can guess, the UUID is a 16-bytes array that can be also translatable to text(UUID v4).
My custom type is converting from binary and to binary, and I also have a JSON marshaller which un/marshaling text to the binary version.
The thing is, the grpc-gateway treat that as
binary
, and embed this code instead of handling the UUID from GET param as string(and use the JSON Unmarshaller):The text was updated successfully, but these errors were encountered: