Skip to content

Instantly share code, notes, and snippets.

💭
🤔

syossan27 syossan27

Block or report user

Report or block syossan27

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sample-recover-format.proto
service Sample {
rpc SampleAPI(Request) returns (Response) {
option (google.api.http) = {
get : "/sample"
};
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary : "サンプル"
responses : {
key : "500"
value : {
View sample-recover.proto
service Sample {
rpc SampleAPI(Request) returns (Response) {
option (google.api.http) = {
get : "/sample"
};
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary : "サンプル"
responses : {
key : "500"
value : {
View sample-broken.proto
service Sample {
rpc SampleAPI(Request) returns (Response) {
option (google.api.http) = {
get: "/sample"
};
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary: "サンプル"
responses: {
key: "500";
value : {
View sample.proto
service Sample {
rpc SampleAPI(Request) returns (Response) {
option (google.api.http) = {
get : "/sample"
};
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary : "サンプル"
responses : {
key : "500";
value : {
View gateway-response.go
func main() {
flag.Parse()
defer glog.Flush()
ctx := context.Background()
opts := gateway.Options{
Addr: ":8080",
GRPCServer: gateway.Endpoint{
Network: *network,
Addr: *endpoint,
View server-response.go
func (s *server) Example(ctx context.Context, in *pb.Request) (*pb.Response, error) {
// Server側のページネーションメッセージ
paginationMessage := &pb.ServerPaginationMessage{
Page: 2,
Limit: 20,
Size: 100,
First: &pb.PaginationMessage{ Page: 1, Limit: 20 },
Last: &pb.PaginationMessage{ Page: 5, Limit: 20 },
Next: &pb.PaginationMessage{ Page: 3, Limit: 20 },
Prev: &pb.PaginationMessage{ Page: 1, Limit: 20 },
View balancing-response.proto
message Response {
google.protobuf.Any pagination = 1;
}
// Server側レスポンス
message ServerPaginationMessage {
uint32 page = 1;
uint32 limit = 2;
uint32 size = 3;
PaginationMessage first = 4;
View example.proto
rpc Example (Request) returns (Response) {
option (google.api.http) = {
get: "/example"
};
}
View gateway-response.proto
message Response {
uint32 page = 1;
uint32 limit = 2;
uint32 size = 3;
string first = 4; // 1ページ目URL
string last = 5; // 最終ページURL
string next = 6; // 次ページURL
string prev = 7; // 前ページURL
}
View server-response.proto
message Response {
uint32 page = 1; // 現在のページ数
uint32 limit = 2; // ページに表示するアイテム数
uint32 size = 3; // 全てのアイテム数
PaginationMessage first = 4; // 1ページ目情報
PaginationMessage last = 5; // 最終ページ情報
PaginationMessage next = 6; // 次ページ情報
PaginationMessage prev = 7; // 前ページ情報
}
You can’t perform that action at this time.