vira/hpropagate

Symfony bundle for propagating http headers from incoming requests to the corresponding outgoing requests automatically

Installs: 2 061

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:symfony-bundle

v1.0.3 2024-06-17 14:06 UTC

This package is auto-updated.

Last update: 2025-07-17 16:40:46 UTC


README

This package automatically propagates HTTP headers from inbound to outbound HTTP requests. It also will add a request ID to all monolog logs under req.id to follow the format used in our node services here

Requirements

  • PHP >= 8.1
  • Symfony 6.3.x

The Why

We use a microservice architecture with a growing number of HTTP endpoints. We want to propagate certain HTTP headers received from the incoming HTTP requests to all subsequent outbound HTTP requests without the need for our engineers to do it programmatically in each service:

By default, the following headers are automatically propagated:

  1. x-request-id. If the header is missing from the inbound request, it will be created with a UUID as value.

Apart from x-request-id, only headers received on the incoming request will be propagated to outbound calls.

Installation

composer require vira/hpropagate

Then add the following to your bundles file:

Vira\Hpropagate\ViraHpropagateBundle::class => ['all' => true

Configuration

There is some optional configuration to be able to propagate more headers than just x-request-id:

# config/packages/vira_hpropagate.yaml
vira_hpropagate:
    headers_to_propagate:
      - x-my-custom-header
      - my-other-header