sroze/message-http-adapter
Symfony Message组件的HTTP适配器
dev-master / 1.0.x-dev
2017-10-09 09:40 UTC
Requires
- guzzlehttp/guzzle: ^6.3
This package is auto-updated.
Last update: 2024-08-29 05:04:34 UTC
README
消息也可以来自HTTP消息,或通过HTTP请求发送到其他API。此适配器将帮助您使用Symfony Message组件以非常简单的方式完成这些操作。
用法
有两种场景
接收HTTP消息
- 配置适配器以接收您的消息
# config/packages/message_http_adapter.yaml message_http_adapter: consumers: - path: '/api/do-something' message: 'App\Message\DoSomething'
- 配置Symfony的路由以使用您的HTTP消费者
# app/config/routing.yml http_messages: resource: . type: http_messages
- 发送您的HTTP请求!
curl 'http://localhost:8000/api/do-something' \
-X POST \
--data-binary '{"propertyOfDoSomethingObject": "yourValue"}' --compressed
发送HTTP消息
- 配置生产者
# config/packages/message_http_adapter.yaml message_http_adapter: producers: requestbin: endpoint: 'https://requestb.in/pdjzjmpd'
- 将消息路由到HTTP适配器生产者
# config/packages/ framework: message: routing: 'App\Message\Send3rdPartyNotification': message_http_adapter.producer.requestbin