add addTeams route

This commit is contained in:
Владимир Фёдоров 2025-05-17 01:22:31 +07:00
parent b5f92e0d9b
commit f710207782
6 changed files with 525 additions and 20 deletions

View File

@ -12,8 +12,33 @@ service EveningDetective {
get: "/ping" get: "/ping"
}; };
} }
rpc AddTeams(AddTeamsReq) returns (AddTeamsRsp) {
option (google.api.http) = {
post: "/teams",
body: "*"
};
}
} }
message PingReq {} message PingReq {}
message PingRsp {} message PingRsp {}
message AddTeamsReq {
repeated Team teams = 1;
}
message Team {
string Name = 1;
}
message AddTeamsRsp {
repeated TeamFull teams = 1;
}
message TeamFull {
int64 id = 1;
string Name = 2;
string Password = 3;
}

View File

@ -1,8 +1,11 @@
package app package app
import ( import (
proto "evening_detective/proto"
"context" "context"
proto "evening_detective/proto"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
) )
type Server struct { type Server struct {
@ -16,3 +19,7 @@ func NewServer() *Server {
func (s *Server) Ping(_ context.Context, _ *proto.PingReq) (*proto.PingRsp, error) { func (s *Server) Ping(_ context.Context, _ *proto.PingReq) (*proto.PingRsp, error) {
return &proto.PingRsp{}, nil return &proto.PingRsp{}, nil
} }
func (s *Server) AddTeams(context.Context, *proto.AddTeamsReq) (*proto.AddTeamsRsp, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddTeams not implemented")
}

View File

@ -97,6 +97,210 @@ func (*PingRsp) Descriptor() ([]byte, []int) {
return file_main_proto_rawDescGZIP(), []int{1} return file_main_proto_rawDescGZIP(), []int{1}
} }
type AddTeamsReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Teams []*Team `protobuf:"bytes,1,rep,name=teams,proto3" json:"teams,omitempty"`
}
func (x *AddTeamsReq) Reset() {
*x = AddTeamsReq{}
if protoimpl.UnsafeEnabled {
mi := &file_main_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddTeamsReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddTeamsReq) ProtoMessage() {}
func (x *AddTeamsReq) ProtoReflect() protoreflect.Message {
mi := &file_main_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddTeamsReq.ProtoReflect.Descriptor instead.
func (*AddTeamsReq) Descriptor() ([]byte, []int) {
return file_main_proto_rawDescGZIP(), []int{2}
}
func (x *AddTeamsReq) GetTeams() []*Team {
if x != nil {
return x.Teams
}
return nil
}
type Team struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
}
func (x *Team) Reset() {
*x = Team{}
if protoimpl.UnsafeEnabled {
mi := &file_main_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Team) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Team) ProtoMessage() {}
func (x *Team) ProtoReflect() protoreflect.Message {
mi := &file_main_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Team.ProtoReflect.Descriptor instead.
func (*Team) Descriptor() ([]byte, []int) {
return file_main_proto_rawDescGZIP(), []int{3}
}
func (x *Team) GetName() string {
if x != nil {
return x.Name
}
return ""
}
type AddTeamsRsp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Teams []*TeamFull `protobuf:"bytes,1,rep,name=teams,proto3" json:"teams,omitempty"`
}
func (x *AddTeamsRsp) Reset() {
*x = AddTeamsRsp{}
if protoimpl.UnsafeEnabled {
mi := &file_main_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddTeamsRsp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddTeamsRsp) ProtoMessage() {}
func (x *AddTeamsRsp) ProtoReflect() protoreflect.Message {
mi := &file_main_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddTeamsRsp.ProtoReflect.Descriptor instead.
func (*AddTeamsRsp) Descriptor() ([]byte, []int) {
return file_main_proto_rawDescGZIP(), []int{4}
}
func (x *AddTeamsRsp) GetTeams() []*TeamFull {
if x != nil {
return x.Teams
}
return nil
}
type TeamFull struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"`
Password string `protobuf:"bytes,3,opt,name=Password,proto3" json:"Password,omitempty"`
}
func (x *TeamFull) Reset() {
*x = TeamFull{}
if protoimpl.UnsafeEnabled {
mi := &file_main_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TeamFull) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TeamFull) ProtoMessage() {}
func (x *TeamFull) ProtoReflect() protoreflect.Message {
mi := &file_main_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TeamFull.ProtoReflect.Descriptor instead.
func (*TeamFull) Descriptor() ([]byte, []int) {
return file_main_proto_rawDescGZIP(), []int{5}
}
func (x *TeamFull) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *TeamFull) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *TeamFull) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
var File_main_proto protoreflect.FileDescriptor var File_main_proto protoreflect.FileDescriptor
var file_main_proto_rawDesc = []byte{ var file_main_proto_rawDesc = []byte{
@ -105,14 +309,36 @@ var file_main_proto_rawDesc = []byte{
0x63, 0x74, 0x69, 0x76, 0x65, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x63, 0x74, 0x69, 0x76, 0x65, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70,
0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0x09, 0x0a, 0x07, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x22, 0x09, 0x6f, 0x74, 0x6f, 0x22, 0x09, 0x0a, 0x07, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x22, 0x09,
0x0a, 0x07, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x73, 0x70, 0x32, 0x6d, 0x0a, 0x10, 0x45, 0x76, 0x65, 0x0a, 0x07, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x73, 0x70, 0x22, 0x42, 0x0a, 0x0b, 0x41, 0x64, 0x64,
0x6e, 0x69, 0x6e, 0x67, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x59, 0x0a, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x12, 0x33, 0x0a, 0x05, 0x74, 0x65, 0x61, 0x6d,
0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x20, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e,
0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e,
0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x20, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e,
0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76,
0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x73, 0x70, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x65, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x22, 0x1a, 0x0a,
0x07, 0x12, 0x05, 0x2f, 0x70, 0x69, 0x6e, 0x67, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x04, 0x54, 0x65, 0x61, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x46, 0x0a, 0x0b, 0x41, 0x64, 0x64,
0x54, 0x65, 0x61, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x12, 0x37, 0x0a, 0x05, 0x74, 0x65, 0x61, 0x6d,
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e,
0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76,
0x65, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x46, 0x75, 0x6c, 0x6c, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d,
0x73, 0x22, 0x4a, 0x0a, 0x08, 0x54, 0x65, 0x61, 0x6d, 0x46, 0x75, 0x6c, 0x6c, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a,
0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d,
0x65, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x32, 0xd8, 0x01,
0x0a, 0x10, 0x45, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69,
0x76, 0x65, 0x12, 0x59, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x20, 0x2e, 0x63, 0x72, 0x61,
0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63,
0x74, 0x69, 0x76, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x20, 0x2e, 0x63,
0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74,
0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x73, 0x70, 0x22, 0x0d,
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x69, 0x0a,
0x08, 0x41, 0x64, 0x64, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x63, 0x72, 0x61, 0x62,
0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74,
0x69, 0x76, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x1a,
0x24, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f,
0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x65, 0x61,
0x6d, 0x73, 0x52, 0x73, 0x70, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x3a, 0x01, 0x2a,
0x22, 0x06, 0x2f, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
@ -128,19 +354,27 @@ func file_main_proto_rawDescGZIP() []byte {
return file_main_proto_rawDescData return file_main_proto_rawDescData
} }
var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_main_proto_goTypes = []interface{}{ var file_main_proto_goTypes = []interface{}{
(*PingReq)(nil), // 0: crabs.evening_detective.PingReq (*PingReq)(nil), // 0: crabs.evening_detective.PingReq
(*PingRsp)(nil), // 1: crabs.evening_detective.PingRsp (*PingRsp)(nil), // 1: crabs.evening_detective.PingRsp
(*AddTeamsReq)(nil), // 2: crabs.evening_detective.AddTeamsReq
(*Team)(nil), // 3: crabs.evening_detective.Team
(*AddTeamsRsp)(nil), // 4: crabs.evening_detective.AddTeamsRsp
(*TeamFull)(nil), // 5: crabs.evening_detective.TeamFull
} }
var file_main_proto_depIdxs = []int32{ var file_main_proto_depIdxs = []int32{
0, // 0: crabs.evening_detective.EveningDetective.Ping:input_type -> crabs.evening_detective.PingReq 3, // 0: crabs.evening_detective.AddTeamsReq.teams:type_name -> crabs.evening_detective.Team
1, // 1: crabs.evening_detective.EveningDetective.Ping:output_type -> crabs.evening_detective.PingRsp 5, // 1: crabs.evening_detective.AddTeamsRsp.teams:type_name -> crabs.evening_detective.TeamFull
1, // [1:2] is the sub-list for method output_type 0, // 2: crabs.evening_detective.EveningDetective.Ping:input_type -> crabs.evening_detective.PingReq
0, // [0:1] is the sub-list for method input_type 2, // 3: crabs.evening_detective.EveningDetective.AddTeams:input_type -> crabs.evening_detective.AddTeamsReq
0, // [0:0] is the sub-list for extension type_name 1, // 4: crabs.evening_detective.EveningDetective.Ping:output_type -> crabs.evening_detective.PingRsp
0, // [0:0] is the sub-list for extension extendee 4, // 5: crabs.evening_detective.EveningDetective.AddTeams:output_type -> crabs.evening_detective.AddTeamsRsp
0, // [0:0] is the sub-list for field type_name 4, // [4:6] is the sub-list for method output_type
2, // [2:4] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
} }
func init() { file_main_proto_init() } func init() { file_main_proto_init() }
@ -173,6 +407,54 @@ func file_main_proto_init() {
return nil return nil
} }
} }
file_main_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddTeamsReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_main_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Team); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_main_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddTeamsRsp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_main_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TeamFull); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -180,7 +462,7 @@ func file_main_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_main_proto_rawDesc, RawDescriptor: file_main_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 2, NumMessages: 6,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@ -49,6 +49,32 @@ func local_request_EveningDetective_Ping_0(ctx context.Context, marshaler runtim
} }
func request_EveningDetective_AddTeams_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq AddTeamsReq
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.AddTeams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_EveningDetective_AddTeams_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq AddTeamsReq
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.AddTeams(ctx, &protoReq)
return msg, metadata, err
}
// RegisterEveningDetectiveHandlerServer registers the http handlers for service EveningDetective to "mux". // RegisterEveningDetectiveHandlerServer registers the http handlers for service EveningDetective to "mux".
// UnaryRPC :call EveningDetectiveServer directly. // UnaryRPC :call EveningDetectiveServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@ -80,6 +106,31 @@ func RegisterEveningDetectiveHandlerServer(ctx context.Context, mux *runtime.Ser
}) })
mux.Handle("POST", pattern_EveningDetective_AddTeams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.evening_detective.EveningDetective/AddTeams", runtime.WithHTTPPathPattern("/teams"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_EveningDetective_AddTeams_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_EveningDetective_AddTeams_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil return nil
} }
@ -143,13 +194,39 @@ func RegisterEveningDetectiveHandlerClient(ctx context.Context, mux *runtime.Ser
}) })
mux.Handle("POST", pattern_EveningDetective_AddTeams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/crabs.evening_detective.EveningDetective/AddTeams", runtime.WithHTTPPathPattern("/teams"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_EveningDetective_AddTeams_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_EveningDetective_AddTeams_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil return nil
} }
var ( var (
pattern_EveningDetective_Ping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"ping"}, "")) pattern_EveningDetective_Ping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"ping"}, ""))
pattern_EveningDetective_AddTeams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"teams"}, ""))
) )
var ( var (
forward_EveningDetective_Ping_0 = runtime.ForwardResponseMessage forward_EveningDetective_Ping_0 = runtime.ForwardResponseMessage
forward_EveningDetective_AddTeams_0 = runtime.ForwardResponseMessage
) )

View File

@ -32,12 +32,89 @@
"EveningDetective" "EveningDetective"
] ]
} }
},
"/teams": {
"post": {
"operationId": "EveningDetective_AddTeams",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/evening_detectiveAddTeamsRsp"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/runtimeError"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/evening_detectiveAddTeamsReq"
}
}
],
"tags": [
"EveningDetective"
]
}
} }
}, },
"definitions": { "definitions": {
"evening_detectiveAddTeamsReq": {
"type": "object",
"properties": {
"teams": {
"type": "array",
"items": {
"$ref": "#/definitions/evening_detectiveTeam"
}
}
}
},
"evening_detectiveAddTeamsRsp": {
"type": "object",
"properties": {
"teams": {
"type": "array",
"items": {
"$ref": "#/definitions/evening_detectiveTeamFull"
}
}
}
},
"evening_detectivePingRsp": { "evening_detectivePingRsp": {
"type": "object" "type": "object"
}, },
"evening_detectiveTeam": {
"type": "object",
"properties": {
"Name": {
"type": "string"
}
}
},
"evening_detectiveTeamFull": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "int64"
},
"Name": {
"type": "string"
},
"Password": {
"type": "string"
}
}
},
"protobufAny": { "protobufAny": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion7
const ( const (
EveningDetective_Ping_FullMethodName = "/crabs.evening_detective.EveningDetective/Ping" EveningDetective_Ping_FullMethodName = "/crabs.evening_detective.EveningDetective/Ping"
EveningDetective_AddTeams_FullMethodName = "/crabs.evening_detective.EveningDetective/AddTeams"
) )
// EveningDetectiveClient is the client API for EveningDetective service. // EveningDetectiveClient is the client API for EveningDetective service.
@ -27,6 +28,7 @@ const (
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type EveningDetectiveClient interface { type EveningDetectiveClient interface {
Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingRsp, error) Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingRsp, error)
AddTeams(ctx context.Context, in *AddTeamsReq, opts ...grpc.CallOption) (*AddTeamsRsp, error)
} }
type eveningDetectiveClient struct { type eveningDetectiveClient struct {
@ -46,11 +48,21 @@ func (c *eveningDetectiveClient) Ping(ctx context.Context, in *PingReq, opts ...
return out, nil return out, nil
} }
func (c *eveningDetectiveClient) AddTeams(ctx context.Context, in *AddTeamsReq, opts ...grpc.CallOption) (*AddTeamsRsp, error) {
out := new(AddTeamsRsp)
err := c.cc.Invoke(ctx, EveningDetective_AddTeams_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// EveningDetectiveServer is the server API for EveningDetective service. // EveningDetectiveServer is the server API for EveningDetective service.
// All implementations must embed UnimplementedEveningDetectiveServer // All implementations must embed UnimplementedEveningDetectiveServer
// for forward compatibility // for forward compatibility
type EveningDetectiveServer interface { type EveningDetectiveServer interface {
Ping(context.Context, *PingReq) (*PingRsp, error) Ping(context.Context, *PingReq) (*PingRsp, error)
AddTeams(context.Context, *AddTeamsReq) (*AddTeamsRsp, error)
mustEmbedUnimplementedEveningDetectiveServer() mustEmbedUnimplementedEveningDetectiveServer()
} }
@ -61,6 +73,9 @@ type UnimplementedEveningDetectiveServer struct {
func (UnimplementedEveningDetectiveServer) Ping(context.Context, *PingReq) (*PingRsp, error) { func (UnimplementedEveningDetectiveServer) Ping(context.Context, *PingReq) (*PingRsp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented")
} }
func (UnimplementedEveningDetectiveServer) AddTeams(context.Context, *AddTeamsReq) (*AddTeamsRsp, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddTeams not implemented")
}
func (UnimplementedEveningDetectiveServer) mustEmbedUnimplementedEveningDetectiveServer() {} func (UnimplementedEveningDetectiveServer) mustEmbedUnimplementedEveningDetectiveServer() {}
// UnsafeEveningDetectiveServer may be embedded to opt out of forward compatibility for this service. // UnsafeEveningDetectiveServer may be embedded to opt out of forward compatibility for this service.
@ -92,6 +107,24 @@ func _EveningDetective_Ping_Handler(srv interface{}, ctx context.Context, dec fu
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _EveningDetective_AddTeams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddTeamsReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(EveningDetectiveServer).AddTeams(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: EveningDetective_AddTeams_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(EveningDetectiveServer).AddTeams(ctx, req.(*AddTeamsReq))
}
return interceptor(ctx, in, info, handler)
}
// EveningDetective_ServiceDesc is the grpc.ServiceDesc for EveningDetective service. // EveningDetective_ServiceDesc is the grpc.ServiceDesc for EveningDetective service.
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@ -103,6 +136,10 @@ var EveningDetective_ServiceDesc = grpc.ServiceDesc{
MethodName: "Ping", MethodName: "Ping",
Handler: _EveningDetective_Ping_Handler, Handler: _EveningDetective_Ping_Handler,
}, },
{
MethodName: "AddTeams",
Handler: _EveningDetective_AddTeams_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "main.proto", Metadata: "main.proto",