-
Notifications
You must be signed in to change notification settings - Fork 0
ApiGateway
Configuration and helpers for communicating with your gateway service.
Set the base URL of your gateway in config/microservice.php
:
'api_gateway' => [
'url' => env('API_GATEWAY_URL', 'http://gateway.local'),
],
The service provider registers four macros on Laravel's HTTP client. They all forward the current correlation ID header.
-
Http::apiGateway()
– default options with retries -
Http::apiGatewayDirect()
– same but without retries -
Http::apiGatewayWithToken($token)
– authenticated requests -
Http::apiGatewayDirectWithToken($token)
– authenticated without retries
See Http-Client-Macros for exception handling details.
Kroderdev\LaravelMicroserviceCore\Services\ApiGatewayClient
wraps these macros with convenient get
, post
, put
and delete
methods:
use Kroderdev\LaravelMicroserviceCore\Services\ApiGatewayClient;
$response = ApiGatewayClient::make()->get('/users');
A factory is bound for dependency injection so you can type-hint ApiGatewayClient
or ApiGatewayClientInterface
in your services.
Use Http::apiGateway()
and related macros for service-to-service calls. Each macro automatically forwards the current correlation ID.
Errors returned by the gateway throw an ApiGatewayException
with the same status code.
Maintained by @KroderDev
💬 Feedback? Open an issue
Last updated: July 1, 2025