Last active
April 24, 2019 10:31
-
-
Save syossan27/1cb2e8bf59008a7150d12cc84a3f00fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }, | |
} | |
// ページネーションメッセージをシリアライズし、Any型に埋め込む | |
serialized, err := proto.Marshal(paginationMessage) | |
if err != nil { | |
return nil, err | |
} | |
paginationAnyMessage = &any.Any{ | |
TypeUrl: proto.MessageName(paginationMessage), | |
Value: serialized, | |
} | |
return &pb.Response{ | |
Pagination: paginationAnyMessage, | |
}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment