Add missing GRPC data field (#412)
* feat(grpc): add support for data field in request body * docs: update Readme with embedmd
This commit is contained in:
parent
33cddfa421
commit
201413967c
22
README.md
22
README.md
|
@ -839,6 +839,7 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"log"
|
||||
|
||||
"github.com/appleboy/gorush/rpc/proto"
|
||||
|
@ -873,6 +874,16 @@ func main() {
|
|||
LocKey: "Test loc key",
|
||||
LocArgs: []string{"test", "test"},
|
||||
},
|
||||
Data: &structpb.Struct{
|
||||
Fields: map[string]*structpb.Value{
|
||||
"key1": {
|
||||
Kind: &structpb.Value_StringValue{StringValue: "welcome"},
|
||||
},
|
||||
"key2": {
|
||||
Kind: &structpb.Value_NumberValue{NumberValue: 2},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("could not greet: %v", err)
|
||||
|
@ -929,6 +940,7 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"log"
|
||||
|
||||
"github.com/appleboy/gorush/rpc/proto"
|
||||
|
@ -963,6 +975,16 @@ func main() {
|
|||
LocKey: "Test loc key",
|
||||
LocArgs: []string{"test", "test"},
|
||||
},
|
||||
Data: &structpb.Struct{
|
||||
Fields: map[string]*structpb.Value{
|
||||
"key1": {
|
||||
Kind: &structpb.Value_StringValue{StringValue: "welcome"},
|
||||
},
|
||||
"key2": {
|
||||
Kind: &structpb.Value_NumberValue{NumberValue: 2},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("could not greet: %v", err)
|
||||
|
|
2
go.mod
2
go.mod
|
@ -20,8 +20,8 @@ require (
|
|||
github.com/emirpasic/gods v0.0.0-20170204130913-fc3e4a43ff31 // indirect
|
||||
github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect
|
||||
github.com/gin-gonic/gin v0.0.0-20170929084810-b8b68314faa0
|
||||
github.com/gogo/protobuf v1.1.1
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
|
||||
github.com/golang/protobuf v1.2.0
|
||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049 // indirect
|
||||
github.com/hashicorp/hcl v0.0.0-20171017181929-23c074d0eceb // indirect
|
||||
github.com/json-iterator/go v0.0.0-20170713110145-8b0360418449 // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -40,8 +40,6 @@ github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 h1:AzN37oI0cOS+cou
|
|||
github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
|
||||
github.com/gin-gonic/gin v0.0.0-20170929084810-b8b68314faa0 h1:9NJhszAM+V+E0qESsPI3EGhCINyqzDWAwC0/dPEUexM=
|
||||
github.com/gin-gonic/gin v0.0.0-20170929084810-b8b68314faa0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y=
|
||||
github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"log"
|
||||
|
||||
"github.com/appleboy/gorush/rpc/proto"
|
||||
|
@ -36,6 +37,16 @@ func main() {
|
|||
LocKey: "Test loc key",
|
||||
LocArgs: []string{"test", "test"},
|
||||
},
|
||||
Data: &structpb.Struct{
|
||||
Fields: map[string]*structpb.Value{
|
||||
"key1": {
|
||||
Kind: &structpb.Value_StringValue{StringValue: "welcome"},
|
||||
},
|
||||
"key2": {
|
||||
Kind: &structpb.Value_NumberValue{NumberValue: 2},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("could not greet: %v", err)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,5 @@
|
|||
syntax = "proto3";
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
package proto;
|
||||
|
||||
|
@ -29,6 +30,7 @@ message NotificationRequest {
|
|||
bool contentAvailable = 11;
|
||||
string threadID = 12;
|
||||
bool mutableContent = 13;
|
||||
google.protobuf.Struct data = 14;
|
||||
}
|
||||
|
||||
message NotificationReply {
|
||||
|
|
|
@ -82,6 +82,13 @@ func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*prot
|
|||
}
|
||||
}
|
||||
|
||||
if in.Data != nil {
|
||||
notification.Data = map[string]interface{}{}
|
||||
for k, v := range in.Data.Fields {
|
||||
notification.Data[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
go gorush.SendNotification(notification)
|
||||
|
||||
return &proto.NotificationReply{
|
||||
|
|
Loading…
Reference in New Issue