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.
- Create project via composer
composer create-project integer-net/callback-proxy
- Set up web server with document root in
public
.
-
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/*
.
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.
Please see CHANGELOG for more information on what has changed recently.
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/
Please see CONTRIBUTING for details.
If you discover any security related issues, please email fs@integer-net.de instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.