Skip to content

Commit cb43dbc

Browse files
Configurable header names and pass-through
2 parents 0714470 + 6705f56 commit cb43dbc

File tree

15 files changed

+251
-45
lines changed

15 files changed

+251
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/vendor/
22
/tools/
33
/bin/
4+
/tmp/
45
/.phpunit.cache/
56
composer.lock

.phive/phars.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="grumphp" version="^2.5.0" installed="2.5.0" location="./tools/grumphp" copy="false"/>
3+
<phar name="grumphp" version="^2.5.0" installed="2.5.0" location="./bin/grumphp" copy="false"/>
4+
<phar name="phpmd" version="^2.15.0" installed="2.15.0" location="./bin/phpmd" copy="false"/>
5+
<phar name="phpcs" version="^3.7.1" installed="3.7.1" location="./bin/phpcs" copy="false"/>
6+
<phar name="phpstan" version="^1.9.2" installed="1.9.2" location="./bin/phpstan" copy="false"/>
47
</phive>

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,29 @@ This is a Symfony bridge for the framework agnostic [Correlation ID library](htt
1414
* [The value of a correlation ID](https://blog.rapid7.com/2016/12/23/the-value-of-correlation-ids/)
1515
* [Identity Correlation on Wikipedia](https://en.wikipedia.org/wiki/Identity_correlation)
1616

17+
## Installation
18+
19+
```sh
20+
composer require phauthentic/correlation-id-symfony-bundle
21+
```
22+
23+
## Configuration
24+
25+
You can configure three different settings to control the behavior:
26+
27+
* `response_header_name` - The name of the response header for the ID.
28+
* `request_header_name` - The name of the request header for the ID.
29+
* `pass_through` - If the ID from the request should be passed to the response enable this. This is useful if you are dealing with a microservice that is not exposed to the public but gets further actions delegated from the entry point and must retain the original ID.
30+
31+
`config/correlation_id.yaml`:
32+
33+
```yaml
34+
correlation_id:
35+
response_header_name: 'X-Correlation-ID'
36+
request_header_name: 'X-Correlation-ID'
37+
pass_through: false
38+
```
39+
1740
## Copyright & License
1841
1942
Licensed under the [MIT license](LICENSE).

composer.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/correlation_id.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
correlation_id:
2+
response_header_name: 'X-Correlation-ID'
3+
request_header_name: 'X-Correlation-ID'

config/services.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
services:
22
Phauthentic\CorrelationIdBundle\EventSubscriber\CorrelationIdSubscriber:
3+
arguments:
4+
$config:
5+
response_header_name: '%correlation_id.response_header_name%'
6+
request_header_name: '%correlation_id.request_header_name%'
7+
pass_through: '%correlation_id.pass_through%'
38
tags:
49
- { name: 'kernel.event_subscriber' }

grumphp.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
grumphp:
2+
ascii:
3+
failed: resources/grumphp-grumpy.txt
4+
succeeded: resources/grumphp-happy.txt
5+
fixer:
6+
enabled: true
7+
fix_by_default: true
8+
tasks:
9+
phpstan:
10+
autoload_file: ~
11+
configuration: phpstan.neon
12+
level: null
13+
force_patterns: []
14+
ignore_patterns: []
15+
triggered_by: ['php']
16+
memory_limit: "-1"
17+
use_grumphp_paths: true
18+
phpmd:
19+
whitelist_patterns: []
20+
exclude: []
21+
report_format: text
22+
ruleset: ['cleancode', 'codesize', 'naming', 'design', 'unusedcode']
23+
triggered_by: ['php']
24+
phpcs:
25+
standard: []
26+
severity: ~
27+
error_severity: ~
28+
warning_severity: ~
29+
tab_width: ~
30+
report: full
31+
report_width: ~
32+
whitelist_patterns: []
33+
encoding: ~
34+
ignore_patterns: []
35+
sniffs: []
36+
triggered_by: [php]
37+
exclude: []
38+
show_sniffs_error_path: true
39+
phpunit:
40+
config_file: phpunit.xml.dist
41+
testsuite: ~
42+
group: []
43+
exclude_group: []
44+
always_execute: false
45+
order: null

phpunit.xml.dist

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="tests/bootstrap.php" cacheDirectory=".phpunit.cache">
4-
<php>
5-
<ini name="display_errors" value="1"/>
6-
<ini name="error_reporting" value="-1"/>
7-
<server name="APP_ENV" value="test" force="true"/>
8-
<server name="SHELL_VERBOSITY" value="-1"/>
9-
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
10-
<server name="SYMFONY_PHPUNIT_VERSION" value="10.5.15"/>
11-
</php>
12-
<testsuites>
13-
<testsuite name="Project Test Suite">
14-
<directory>tests</directory>
15-
</testsuite>
16-
</testsuites>
17-
<coverage>
18-
<include>
19-
<directory suffix=".php">src</directory>
20-
</include>
21-
</coverage>
4+
<php>
5+
<ini name="display_errors" value="1"/>
6+
<ini name="error_reporting" value="-1"/>
7+
<server name="APP_ENV" value="test" force="true"/>
8+
<server name="SHELL_VERBOSITY" value="-1"/>
9+
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
10+
<server name="SYMFONY_PHPUNIT_VERSION" value="10.5.15"/>
11+
</php>
12+
<testsuites>
13+
<testsuite name="Project Test Suite">
14+
<directory>tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
<source>
18+
<include>
19+
<directory suffix=".php">src</directory>
20+
</include>
21+
</source>
2222
</phpunit>

resources/grumphp-grumpy.txt

Whitespace-only changes.

resources/grumphp-happy.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
All good!

0 commit comments

Comments
 (0)