cli: Add hook name to gRPC message (#364)
* Make use of gRPC metadatas to pass on Hook-Name. Fixes #362 * Add Hook name in proto. * Pass the hook name into the hook proto instead of gRPC metadatas. Co-authored-by: Clément Peyrabère <clement.peyrabere@idcapture.fr>
This commit is contained in:
parent
e5e9a74c66
commit
acfa974c10
|
@ -37,7 +37,7 @@ func (g *GrpcHook) Setup() error {
|
|||
|
||||
func (g *GrpcHook) InvokeHook(typ HookType, info handler.HookEvent, captureOutput bool) ([]byte, int, error) {
|
||||
ctx := context.Background()
|
||||
req := &pb.SendRequest{Hook: marshal(info)}
|
||||
req := &pb.SendRequest{Hook: marshal(typ, info)}
|
||||
resp, err := g.Client.Send(ctx, req)
|
||||
if err != nil {
|
||||
if e, ok := status.FromError(err); ok {
|
||||
|
@ -51,7 +51,7 @@ func (g *GrpcHook) InvokeHook(typ HookType, info handler.HookEvent, captureOutpu
|
|||
return nil, 0, err
|
||||
}
|
||||
|
||||
func marshal(info handler.HookEvent) *pb.Hook {
|
||||
func marshal(typ HookType, info handler.HookEvent) *pb.Hook {
|
||||
return &pb.Hook{
|
||||
Upload: &pb.Upload{
|
||||
Id: info.Upload.ID,
|
||||
|
@ -69,5 +69,6 @@ func marshal(info handler.HookEvent) *pb.Hook {
|
|||
Uri: info.HTTPRequest.URI,
|
||||
RemoteAddr: info.HTTPRequest.RemoteAddr,
|
||||
},
|
||||
Name: string(typ),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ message Hook {
|
|||
// HTTPRequest contains details about the HTTP request that reached
|
||||
// tusd.
|
||||
HTTPRequest httpRequest = 2;
|
||||
// The hook name
|
||||
string name = 3;
|
||||
}
|
||||
|
||||
// Request data to send hook
|
||||
|
|
Loading…
Reference in New Issue