integer-net / callback-proxy
A proxy to dispatch callback requests to multiple targets. Useful to share payment integrations with multiple (e.g. test) systems.
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 14
Forks: 0
Open Issues: 3
Type:project
Requires
- php: ^7.1.0
- ext-spl: *
- guzzlehttp/guzzle: ^6.3
- namshi/cuzzle: ^2.0
- psr/http-message: ^1.0
- roave/security-advisories: dev-master
- slim/slim: ^3.0
Requires (Dev)
- infection/infection: ^0.10.5
- jakub-onderka/php-parallel-lint: ^1.0
- maglnet/composer-require-checker: ^1.1
- pds/skeleton: ^1.0
- phan/phan: ^1.1
- phpmd/phpmd: ^2.6
- phpro/grumphp: ^0.14.2
- phpstan/phpstan: ^0.10.3
- phpunit/phpunit: ^7.4
- squizlabs/php_codesniffer: ^3.3
This package is auto-updated.
Last update: 2024-10-15 22:15:51 UTC
README
This is a service to integrate third party integrations with multiple environments, typically test systems.
It can distribute callbacks to several systems, for example:
proxy.example.com/paypal-dev/postBack
=>
dev1.example.com/paypal/postBack
dev2.example.com/paypal/postBack
dev3.example.com/paypal/postBack
The first successful response is returned. If no response was successful (HTTP status code 200), the last response is returned.
If it is used for dev systems, only the proxy must be made accessible from outside by the third party, instead of all target systems.
Installation
- Create project via composer
composer create-project integer-net/callback-proxy
- Set up web server with document root in
public
.
Configuration
-
Copy
config.php.sample
toconfig.php
. -
Adjust the
proxy/targets
configuration, e.g.:'proxy' => [ 'targets' => [ 'paypal-dev' => [ 'https://dev1.example.com/paypal/', 'https://dev2.example.com/paypal/', ], ], ],
This example routes
/paypal-dev/*
tohttps://dev1.example.com/paypal/*
andhttps://dev2.example.com/paypal/*
.
Advanced Configuration
Instead of a plain URI string, each target can also be configured with additional options:
[
'uri' => 'https://dev1.example.com/paypal/',
'basic-auth' => 'username:password',
]
- uri (required) - the base URI
- basic-auth - HTTP basic authentication in the form "username:password"
The default dispatcher strategy is to dispatch the request to all targets and return the first successful (2xx) response.
You can choose a different strategy in config.php
:
'proxy' => [
'strategy' => \IntegerNet\CallbackProxy\DispatchStrategy\DispatchAllReturnFirstSuccess::class,
]
Available Strategies:
\IntegerNet\CallbackProxy\DispatchStrategy\DispatchAllReturnFirstSuccess::class
- the default strategy, see above\IntegerNet\CallbackProxy\DispatchStrategy\StopOnFirstSucces::class
- returns the first successful (2xx) response, stops dispatching further targets
You can implement your own strategies, by implementing the \IntegerNet\CallbackProxy\DispatchStrategy
interface.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
composer test
Runs unit tests, mutation tests and static analysis
php -S localhost:9000 -t public
Starts the proxy locally on port 9000 for manual testing. Needs a valid configuration in config.php
. As a generic target URI, you can use https://httpbin.org/anything/
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email fs@integer-net.de instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.