Skip to content

Ensure EmitUnpopulated=true for REST responses #160

@NathanBaulch

Description

@NathanBaulch

I'm new to ConnectRPC and have just finished migrating my grpc-gateway server across to Vanguard.
One regression I'm seeing is related to protojson's EmitUnpopulated which appears to be true in Vanguard but false in the underlying Connect handler. The latter is the response marshaler that's actually being used at runtime. I've done some debugging but there's a lot going on in transcoder.go.

What is the correct way to make sure REST protocol responses are always encoded with the Vanguard JSONCodec?

As far as I can tell, the "Accept: application/json" header is forwarded through and the Connect handler obliges with its own JSON marshaler. I could replace that underlying codec but it seems like there should be a way to accomplish this in the Vanguard layer with no impact on non-REST requests.

Perhaps there's some way to register a "json+emitunpopulated" codec and have Vanguard rewrite the request somehow to instruct the underlying connect handler to use this codec?

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