gregleveque / gateway-bundle
0.3
2020-08-06 21:03 UTC
Requires
- guzzlehttp/guzzle: ^6.5
- symfony/symfony: ^3.4
This package is auto-updated.
Last update: 2024-09-27 17:04:10 UTC
README
Gie Gateway Bundle
目录
安装
composer require gregleveque/gateway-bundle
在 AppKernel.php 中添加
<?php // app/AppKernel.php public function registerBundles() { $bundles = [ // ... new Gie\GatwayBundle\GieGatewayBundle(), // ... ]; }
配置
gie_gateway: redis_dsn: 127.0.0.1 # default value routes: name: target: https://www.target.com query: a: - first - second b: 3 headers: Content-Type: application/json ttl: 60 # default value
当使用配置中定义的路由时,客户端参数 始终 覆盖配置参数。对于查询字符串,如果变量是数组,客户端默认替换第一个值。
- 如果您需要从数组中替换已配置的值,请使用查询字符串中值的索引
...&a[1]=replaced
- 如果您需要在数组中添加新值,请使用未使用的索引
...&a=[3]=added
客户端使用
- 基本路由
/api/gateway
- 已配置的路由
/api/gateway/{route-name}
当使用默认路由或已配置的路由时,存在2个自定义头
- X_GATEWAY_FORWARD: 由逗号分隔的转发头列表。
- X_GATEWAY_TTL: 更改响应的默认 TTL(默认 60 秒)