Skip to content

custom codec examples dont work when using on client not build with rust #2017

@codeitlikemiley

Description

@codeitlikemiley

I have re-created the examples for json-codec

https://github.com/codeitlikemiley/json-codec

from:

https://github.com/hyperium/tonic/blob/master/examples/src/json-codec/server.rs
https://github.com/hyperium/tonic/blob/master/examples/src/json-codec/common.rs
https://github.com/hyperium/tonic/blob/master/examples/src/json-codec/client.rs

I am experimenting on it , if i can reduced as much as code

i wonder if i can use this concept of custom codec with duplex connection

with axum and tonic:
https://github.com/codeitlikemiley/duplex-server-rs/blob/61c088d0c5554272a2eb5a79915abeed4d201797/src/main.rs#L35

that example is already working , but

what i had in mind is if we just run tonic alone , and pass

on headers application/json for content type

would be able to use client like grpcurl , curl, postman?

That when i found out that we cant

on the premise that we are being required to have tonic-reflection

in our case we are using tonic::manual

as such there is not config to specify a proto

and defining or re-creating a proto file in our case hello-world.proto

would have codec discrepancy as it would use the default ProstCodec and not the JsonCodec

So im a kinda stuck on a loop , and would like to know if anyone have success on using this on real world project

as the example alone is only useful if the client was built with rust, what if our client is on js
or using curl, grpcup or postman etc.

I couldnt wrap it around my head on how to make best use of custom codec

as its impossible to use on different client as those clients dont expect json

or am i missing something out ....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions