qiajigou / c3po-grpc-gateway

A light weight Python grpc gateway with tornado named c3po.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use Google.Api.Http option instead of custom option

taliesins opened this issue · comments

Perhaps it would be better to use the Google Extensions for Http Rule instead of creating a custom one.

syntax = "proto3";

package GrpcExample;

import "google/api/annotations.proto";

message Quoted {
  int64 id = 1;
}

message QuotedProduct {
  PriceComponent quotedPrice = 100;
}

message Product {
  string code = 1;
  string name = 2;
  QuotedProduct quotedProduct = 3;  
}

message Ordered {
  int64 id = 1;
  repeated QuotedProduct products = 2;
  enum Status {
    placed = 0;
    approved = 1;
    delivered = 2;
  }
  Status status = 3; //Order Status
  bool complete = 4;
}

message PriceComponent {
  double amount = 1;
  string currency = 2;
}

message PlaceQuoteRequest{
    Quoted quoted = 1;
}

message PlaceQuoteResponse{
}

message GetOrderRequest{
    int64 orderId = 1; //ID of pet that needs to be fetched
}

message GetOrderResponse{
  Ordered ordered = 1;
}

message DeleteOrderRequest{
  int64 orderId = 1; //ID of the order that needs to be deleted
}

message DeleteOrderResponse{
  Ordered ordered = 1;
}

service Order {
  /* Place an order for quoting */
  rpc PlaceQuote(PlaceQuoteRequest) returns (PlaceQuoteResponse) {
    option (google.api.http) = {
      post: "/v2/store/order/quote"
      body: "*"
    };
  }
  
  /* Find purchase order by ID */
  rpc GetOrder(GetOrderRequest) returns (GetOrderResponse) {
    option (google.api.http) = {
      get: "/v2/store/order/{orderId}"
    };
  }

  /* Delete purchase order by ID */
  rpc DeleteOrder(DeleteOrderRequest) returns (DeleteOrderResponse) {
    option (google.api.http) = {
      delete: "/v2/store/order/{orderId}"
    };
  }
}

Thanks, let's think about this. @zhongql