grpc icon indicating copy to clipboard operation
grpc copied to clipboard

Feat/http transcoding (Continuation)

Open sleipnir opened this issue 1 year ago • 1 comments
trafficstars

This PR continues the excellent work started by @drowzy in his PR https://github.com/elixir-grpc/grpc/pull/273. The merit of this work must be given entirely to @drowzy.

I just made some small fixes and eliminated all the deprecated code from the Protobuf api, as well as merging it with the recent codebase and fixing some tests.

I hope @drowzy doesn't mind that I picked up where he left off. But I accept it if you don't want to continue with this PR here. Again I reiterate that he did an excellent job in his previous PR.

Below is the text copied from the original PR (https://github.com/elixir-grpc/grpc/pull/273):

Support for gRPC transcoding.

  • Closes https://github.com/elixir-grpc/grpc/issues/192
  • Closes https://github.com/elixir-grpc/grpc/issues/274

This feature is opt-in using the http_transcode option in the server definition:

defmodule Helloworld.Greeter.Server do
  use GRPC.Server,
    service: Helloworld.Greeter.Service,
    http_transcode: true

Request/response mapping can be controlled by adding grpc-gateway annotations to your proto definition:

import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";

package helloworld;

// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "/v1/greeter/{name}"
    };
  }

  rpc SayHelloFrom (HelloRequestFrom) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/greeter"
      body: "*"
    };
  }
}

This PR does not require any changes to user code.

For a full list of features see https://github.com/elixir-grpc/grpc/pull/273

sleipnir avatar Feb 16 '24 01:02 sleipnir

ping @polvalente @drowzy

sleipnir avatar Mar 04 '24 14:03 sleipnir

Thank you @polvalente

sleipnir avatar Mar 26 '24 17:03 sleipnir