1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// import gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
// Do not send x-ndjson for gwruntime.MIMEWildcard (*)
gwruntime.WithMarshalerOption(gwruntime.MIMEWildcard, &marshaller.HTTPBodyMarshaler{
Marshaler: &gwruntime.JSONPb{
MarshalOptions: protojson.MarshalOptions{
UseProtoNames: true,
EmitUnpopulated: false,
},
UnmarshalOptions: protojson.UnmarshalOptions{
DiscardUnknown: true,
},
},
}),
// send newline delimeted json if client sends the corresponding accept type
gwruntime.WithMarshalerOption("application/x-ndjson", &gwruntime.HTTPBodyMarshaler{
Marshaler: &gwruntime.JSONPb{
MarshalOptions: protojson.MarshalOptions{
UseProtoNames: true,
EmitUnpopulated: false,
},
UnmarshalOptions: protojson.UnmarshalOptions{
DiscardUnknown: true,
},
},
}),
}
|