You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by sh...@apache.org on 2022/06/07 06:47:56 UTC
[rocketmq-eventbridge] branch main updated (a785488 -> 22f06dc)
This is an automated email from the ASF dual-hosted git repository.
shenlin pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/rocketmq-eventbridge.git
from a785488 Bump gson from 2.8.7 to 2.8.9 in /supports/connect-eventbridge-transform
new 3741398 Supplement http source documentation
new 22f06dc Optimize http source usage instructions
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
README.md | 80 +++++++++++++++++++++-
.../adapter/api/converter/HttpEventConverter.java | 2 +-
2 files changed, 79 insertions(+), 3 deletions(-)
[rocketmq-eventbridge] 02/02: Optimize http source usage instructions
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shenlin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/rocketmq-eventbridge.git
commit 22f06dc15cba2f96df59291a7b433408bb72c157
Author: changfeng <yo...@alibaba-inc.com>
AuthorDate: Thu May 19 17:06:38 2022 +0800
Optimize http source usage instructions
---
README.md | 27 ++++++++++------------
.../adapter/api/converter/HttpEventConverter.java | 2 +-
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/README.md b/README.md
index 11c16a4..201d646 100644
--- a/README.md
+++ b/README.md
@@ -148,31 +148,28 @@ http://127.0.0.1:7001/source/createEventSource
Http request to access this webhook will be converted into a CloudEvent and delivered to eventbus.
```
-http://127.0.0.1/webhook/putEvents?token=43146d108b2123
-Header: Content-Type:"application/json"
-```
-```json
-{
- "username": "testUser",
- "testData": "testData"
-}
+curl -d '{"username": "testUser", "testData": "testData"}' -H 'Content-Type: application/json' -H 'Accept-Language: en-US' http://127.0.0.1:7001/webhook/putEvents?token=43146d108b224eb2adc581aedd28f272007320d14b9d
```
+
generated CloudEvent demo
```json
{
"datacontenttype": "application/json",
"data": {
- "headers": {
- "Accecpt": "*/*",
- "Host": "127.0.0.1:7001",
- "Content-Type": "none"
- },
- "path": "/webhook/putEvents",
"body": {
"username": "testUser",
"testData": "testData"
},
- "httpMethod": "GET",
+ "headers": {
+ "Accept": "*/*",
+ "User-Agent": "curl/7.64.1",
+ "Host": "127.0.0.1:7001",
+ "Accept-Language": "en-US",
+ "Content-Length": "48",
+ "Content-Type": "application/json"
+ },
+ "httpMethod": "POST",
+ "path": "/webhook/putEvents",
"queryString": {}
},
"subject": "DemoBus/httpEventSourceDemo",
diff --git a/adapter/api/src/main/java/org/apache/rocketmq/eventbridge/adapter/api/converter/HttpEventConverter.java b/adapter/api/src/main/java/org/apache/rocketmq/eventbridge/adapter/api/converter/HttpEventConverter.java
index 6e547ee..7e485ea 100644
--- a/adapter/api/src/main/java/org/apache/rocketmq/eventbridge/adapter/api/converter/HttpEventConverter.java
+++ b/adapter/api/src/main/java/org/apache/rocketmq/eventbridge/adapter/api/converter/HttpEventConverter.java
@@ -237,7 +237,7 @@ public class HttpEventConverter {
httpEventData.setBody(bodyContent);
httpEventData.setHeaders(dataHeaders);
httpEventData.setHttpMethod(request.getMethod().toString());
- httpEventData.setPath(request.getPath().toString());
+ httpEventData.setPath(request.getPath().pathWithinApplication().value());
HashMap<String, String> queryParam = new HashMap<>();
request.getQueryParams().forEach((k, v) -> {
[rocketmq-eventbridge] 01/02: Supplement http source documentation
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shenlin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/rocketmq-eventbridge.git
commit 3741398ab73098aea195c7c96742d1e5e7bdaeab
Author: changfeng <yo...@alibaba-inc.com>
AuthorDate: Fri May 13 15:57:09 2022 +0800
Supplement http source documentation
---
README.md | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 81 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index b377d89..11c16a4 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ http://127.0.0.1:7001/bus/createEventBus
* Create EventSource
```
-http://127.0.0.1:7001/bus/createEventSource
+http://127.0.0.1:7001/source/createEventSource
```
```json
{
@@ -104,4 +104,83 @@ Header: Content-Type:"application/cloudevents+json; charset=UTF-8"
},
"aliyuneventbusname":"demo"
}
-```
\ No newline at end of file
+```
+* Use HttpSource to put events
+
+EventBridge HttpSource allows you to put events to eventbus in the form of webhook.
+
+Here is an example explaining how to put events using EventBridge HttpSource.
+
+1. Create an EventBridge HttpSource
+
+ - eventSourceName: Name of EventSource
+ - eventBusName: Name of EventBus
+ - description: Description
+ - className: HttpEvent. This parameter is a fixed value and cannot be modified.
+ - config: HttpSource Config
+ - Type: Request type. Available values are 'HTTP', 'HTTPS' and 'HTTP&HTTPS'.
+ - Method: Allowed HTTP request methods. The request will be filtered if the http request method type for accessing the webhook does not meet the configuration.
+ - SecurityConfig: Security configuration type. Available values are 'none', 'ip' and 'referer'.
+ - Ip: IP security configuration. Http requests whose source ip is not in the configured network segment will be filtered if the security configuration is selected as 'ip'.
+ - Referer: Referer security configuration. HTTP requests whose referer is not in this configuration will be filtered if the security configuration is selected as 'referer'.
+
+A webhook will be generated after the creation of HttpSource.
+```
+http://127.0.0.1:7001/source/createEventSource
+```
+```json
+{
+ "eventSourceName": "httpEventSourceDemo",
+ "eventBusName": "demo",
+ "description": "http source demo",
+ "className": "HttpEvent",
+ "config": {
+ "Type": "HTTP&HTTPS",
+ "Method": ["GET", "POST"],
+ "SecurityConfig": "ip",
+ "Ip": ["10.0.0.0/8"],
+ "Referer":[]
+ }
+}
+```
+2. Put event to EventBus
+
+Http request to access this webhook will be converted into a CloudEvent and delivered to eventbus.
+
+```
+http://127.0.0.1/webhook/putEvents?token=43146d108b2123
+Header: Content-Type:"application/json"
+```
+```json
+{
+ "username": "testUser",
+ "testData": "testData"
+}
+```
+generated CloudEvent demo
+```json
+{
+ "datacontenttype": "application/json",
+ "data": {
+ "headers": {
+ "Accecpt": "*/*",
+ "Host": "127.0.0.1:7001",
+ "Content-Type": "none"
+ },
+ "path": "/webhook/putEvents",
+ "body": {
+ "username": "testUser",
+ "testData": "testData"
+ },
+ "httpMethod": "GET",
+ "queryString": {}
+ },
+ "subject": "DemoBus/httpEventSourceDemo",
+ "source": "httpEventSourceDemo",
+ "type": "eventbridge:Events:HTTPEvent",
+ "specversion": "1.0",
+ "id": "75bc099b-130a-45a8-82e1-3f9a7f0d10f3",
+ "time": "2022-05-12T17:20:30.264+08:00"
+}
+```
+