in correlation/grpc/server_interceptors.go [50:66]
func UnaryServerCorrelationInterceptor(opts ...ServerCorrelationInterceptorOption) grpc.UnaryServerInterceptor {
config := applyServerCorrelationInterceptorOptions(opts)
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
ctx, correlationID := extractFromContext(ctx, config.propagateIncomingCorrelationID)
if config.reversePropagateCorrelationID {
sts := grpc.ServerTransportStreamFromContext(ctx)
err := sts.SetHeader(metadata.Pairs(metadataCorrelatorKey, correlationID))
if err != nil {
return nil, err
}
}
return handler(ctx, req)
}
}