2011shenlin commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r858230001


##########
adapter/api/src/main/java/org/apache/rocketmq/eventbridge/adapter/api/converter/HttpEventConverter.java:
##########
@@ -0,0 +1,293 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *     http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+package org.apache.rocketmq.eventbridge.adapter.api.converter;
+
+import com.google.common.net.MediaType;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import io.cloudevents.CloudEvent;
+import io.cloudevents.core.v1.CloudEventBuilder;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.rocketmq.eventbridge.adapter.api.dto.data.HttpEventData;
+import org.apache.rocketmq.eventbridge.domain.cache.EventSourceCacheService;
+import org.apache.rocketmq.eventbridge.domain.model.source.EventSource;
+import org.apache.rocketmq.eventbridge.exception.EventBridgeException;
+import org.apache.rocketmq.eventbridge.tools.ARNHelper;
+import org.apache.rocketmq.eventbridge.tools.NetUtil;
+import org.apache.rocketmq.eventbridge.tools.transform.Data;
+import org.apache.rocketmq.eventbridge.tools.transform.StringData;
+import org.apache.rocketmq.eventbridge.tools.transform.Transform;
+import org.apache.rocketmq.eventbridge.tools.transform.TransformBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.lang.reflect.Type;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.time.OffsetDateTime;
+import java.time.ZonedDateTime;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import static 
org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.JSON_ATTRIBUTE_INVALID;
+import static 
org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.PutEventsRequestSecurityCheckFailed;
+import static 
org.apache.rocketmq.eventbridge.domain.model.source.HTTPEventSourceService.SECURITY_CONFIG_IP;
+import static 
org.apache.rocketmq.eventbridge.domain.model.source.HTTPEventSourceService.SECURITY_CONFIG_NONE;
+import static 
org.apache.rocketmq.eventbridge.domain.model.source.HTTPEventSourceService.SECURITY_CONFIG_REFERER;
+
+/**
+ * @Author changfeng
+ * @Date 2022/4/25 11:28 上午
+ */
+@Service
+public class HttpEventConverter {
+    private static final Logger logger = 
LoggerFactory.getLogger(HttpEventConverter.class);
+
+    @Autowired
+    EventSourceCacheService eventSourceCacheService;
+
+    private static final String TYPE = "eventbridge:Events:HTTPEvent";
+    private static final String DATA_CONTENT_TYPE = "application/json";
+
+    private static final String HEADER_X_REAL_IP = "x-real-ip";
+    public static final String HEADER_EVENTBRIDGE_DATE = "x-eventbridge-date";
+
+    private static final String SECURITY_CONFIG = "SecurityConfig";
+    private static final String IP_CONFIG = "Ip";
+    private static final String METHOD_CONFIG = "Method";
+    private static final String REFERER_CONFIG = "Referer";
+
+    public static final String EXTENSION_REGIONID = "aliyunregionid";
+    public static final String EXTENSION_ACCOUNTID = "aliyunaccountid";
+    public static final String EXTENSION_PUBLISHADDR = "aliyunpublishaddr";

Review Comment:
   Remove the code around aliyun, if needed , change to the SPI  and move the 
impl to rpc package.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to