cli: Pass headers to gRPC hooks (#813)
Co-authored-by: Kaltenbach, Jonas <jonas.kaltenbach@zoi.de>
This commit is contained in:
parent
920deb3df7
commit
707f41be2b
|
@ -2,6 +2,7 @@ package hooks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
|
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
|
||||||
|
@ -66,12 +67,22 @@ func marshal(hookReq HookRequest) *pb.HookRequest {
|
||||||
Method: event.HTTPRequest.Method,
|
Method: event.HTTPRequest.Method,
|
||||||
Uri: event.HTTPRequest.URI,
|
Uri: event.HTTPRequest.URI,
|
||||||
RemoteAddr: event.HTTPRequest.RemoteAddr,
|
RemoteAddr: event.HTTPRequest.RemoteAddr,
|
||||||
// TODO: HEaders
|
Header: getHeaders(event.HTTPRequest.Header),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getHeaders(httpHeader http.Header) (hookHeader map[string]string) {
|
||||||
|
hookHeader = make(map[string]string)
|
||||||
|
for key, val := range httpHeader {
|
||||||
|
if key != "" && val != nil && len(val) > 0 {
|
||||||
|
hookHeader[key] = val[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hookHeader
|
||||||
|
}
|
||||||
|
|
||||||
func unmarshal(res *pb.HookResponse) (hookRes HookResponse) {
|
func unmarshal(res *pb.HookResponse) (hookRes HookResponse) {
|
||||||
hookRes.RejectUpload = res.RejectUpload
|
hookRes.RejectUpload = res.RejectUpload
|
||||||
hookRes.StopUpload = res.StopUpload
|
hookRes.StopUpload = res.StopUpload
|
||||||
|
|
Loading…
Reference in New Issue