demroos/api-gateway-bundle
Composer 安装命令:
composer require demroos/api-gateway-bundle
包简介
This bundle will help you make api gateway
README 文档
README
This bundle enables you to easily proxy requests. It stands as a gateway between your API and a number of external services.
About package
This package will help you create an api gateway.
Features
- Getting endpoints from bundle configuration
- Getting endpoints from loaders, see EndpointLoaderInterface
- Feature for processing body request/response is coming soon
Install
composer require demroos/api-gateway-bundle
Enable bundle
in config/bundles.php
<?php return [ // other bundles, Demroos\Bundle\ApiGatewayBundle\ApiGatewayBundle::class => ['all' => true] ];
add to config/routes.yml
api_gateway: resource: '@ApiGatewayBundle/Resources/config/routes.xml'
Config
Config endpoints
in api_gateway.yml
api_gateway: config: headers: - 'Content-Type' endpoints: api_example: url: '/api/example' method: 'POST' config: url: 'https://example.com/api/example' method: 'POST'
Load endpoint from loader
- You create a service that implements the EndpointLoaderInterface interface
- You add tag
api_gateway.endpoint_loaderfor this service
<?php namespace App\Routing; use Demroos\Bundle\ApiGatewayBundle\Contracts\EndpointLoaderInterface; use Demroos\Bundle\ApiGatewayBundle\Endpoint; class ExampleEndpointLoader implements EndpointLoaderInterface { public function load(): array { $endpoints = []; $endpoint = new Endpoint( 'api_example', '/api/example', 'POST' ); $endpoints[] = $endpoint; return $endpoints; } }
in config/services.yaml
services: App\Routing\ExampleEndpointLoader: tags: [api_gateway.endpoint_loader]
Config client factory
in api_gateway.yml
api_gateway: client_factory: #service: id_service_for_use_as_client_factory config: http_errors: false
Support PHP
| ApiGatewayBundle | PHP | Symfony |
|---|---|---|
| [0.1] (develop) | >=7.4 | ^4.3|^5.0 |
| [0.0] (0.0) | ^7.3 | ^4.3|^5.0 |
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-15