GRPC请求增加header自定义参数

话不多说直接上代码

private var  stub:ReaderGrpc.ReaderBlockingStub?=null
stub = ReaderGrpc.newBlockingStub(CHANNEL)
var meadata = Metadata()
meadata.put(Metadata.Key.of("paramas1", Metadata.ASCII_STRING_MARSHALLER),"1")
meadata.put(Metadata.Key.of("paramas2", Metadata.ASCII_STRING_MARSHALLER), "2")
stub = MetadataUtils.attachHeaders(stub, meadata)

你可能感兴趣的:(GRPC请求增加header自定义参数)