You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
974 B
34 lines
974 B
// 定义项目 API 的 proto 文件 可以同时描述 gRPC 和 HTTP API
|
|
// protobuf 文件参考:
|
|
// - https://developers.google.com/protocol-buffers/
|
|
syntax = "proto3";
|
|
|
|
import "gogoproto/gogo.proto";
|
|
import "google/protobuf/empty.proto";
|
|
import "google/api/annotations.proto";
|
|
|
|
// package 命名使用 {appid}.{version} 的方式, version 形如 v1, v2 ..
|
|
package demo.service.v1;
|
|
|
|
// NOTE: 最后请删除这些无用的注释 (゜-゜)つロ
|
|
|
|
option go_package = "api";
|
|
option (gogoproto.goproto_getters_all) = false;
|
|
|
|
service Demo {
|
|
rpc Ping(.google.protobuf.Empty) returns (.google.protobuf.Empty);
|
|
rpc SayHello(HelloReq) returns (.google.protobuf.Empty);
|
|
rpc SayHelloURL(HelloReq) returns (HelloResp) {
|
|
option (google.api.http) = {
|
|
get: "/demo/say_hello"
|
|
};
|
|
};
|
|
}
|
|
|
|
message HelloReq {
|
|
string name = 1 [(gogoproto.moretags) = 'form:"name" validate:"required"'];
|
|
}
|
|
|
|
message HelloResp {
|
|
string Content = 1 [(gogoproto.jsontag) = 'content'];
|
|
}
|
|
|