L
L
LakeForest2022-01-15 17:45:49
Python
LakeForest, 2022-01-15 17:45:49

How to add REST API support using google.api.http on gRPC service?

Can you please tell me how to add REST API support using google.api.http?

syntax = "proto3";

import "google/api/annotations.proto";

service TestService {
    rpc Method(MethodRequest) returns (MethodResponse) { 
            option (google.api.http) = {
            post: "/api/v1/test:method"
            body: "*"
        };
    }
}

What should be added here? Or how?
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    stt_pb2_grpc.add_TestServiceServicer_to_server(
        TestService(), server
    )
    address = f"{host}:{port}"
    server.add_insecure_port(address)
    server.start()
    server.wait_for_termination()

It seemed to me that with the addition of option (google.api.http) support is immediately provided, but not a single request passes ... Maybe I'm not sending requests correctly to grpc via api ... Are there any special headers needed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question