diff --git a/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/converter/HttpRowConverter.java b/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/converter/HttpRowConverter.java index 8994c61b78..9aa8331813 100644 --- a/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/converter/HttpRowConverter.java +++ b/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/converter/HttpRowConverter.java @@ -18,12 +18,10 @@ package com.dtstack.chunjun.connector.http.converter; -import com.dtstack.chunjun.connector.http.client.DefaultRestHandler; import com.dtstack.chunjun.connector.http.common.HttpRestConfig; import com.dtstack.chunjun.converter.AbstractRowConverter; import com.dtstack.chunjun.converter.IDeserializationConverter; import com.dtstack.chunjun.converter.ISerializationConverter; -import com.dtstack.chunjun.util.GsonUtil; import com.dtstack.chunjun.util.MapUtil; import org.apache.flink.table.data.DecimalData; @@ -45,7 +43,8 @@ import java.util.Map; /** Base class for all converters that convert between restapi body and Flink internal object. */ -public class HttpRowConverter extends AbstractRowConverter { +public class HttpRowConverter + extends AbstractRowConverter, RowData, RowData, LogicalType> { private HttpRestConfig httpRestConfig; @@ -69,9 +68,7 @@ public HttpRowConverter(RowType rowType) { } @Override - public RowData toInternal(String input) throws Exception { - Map result = - DefaultRestHandler.gson.fromJson(input, GsonUtil.gsonMapTypeToken); + public RowData toInternal(Map result) throws Exception { GenericRowData genericRowData = new GenericRowData(rowType.getFieldCount()); List columns = rowType.getFieldNames(); for (int pos = 0; pos < columns.size(); pos++) { diff --git a/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/table/HttpDynamicTableFactory.java b/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/table/HttpDynamicTableFactory.java index a8752280f2..7e17812605 100644 --- a/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/table/HttpDynamicTableFactory.java +++ b/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/table/HttpDynamicTableFactory.java @@ -72,6 +72,8 @@ public Set> optionalOptions() { options.add(HttpOptions.INTERVALTIME); options.add(HttpOptions.COLUMN); options.add(HttpOptions.DELAY); + options.add(HttpOptions.DATA_SUBJECT); + options.add(HttpOptions.CYCLES); return options; } @@ -142,6 +144,8 @@ private HttpRestConfig getRestapiConf(ReadableConfig config) { httpRestConfig.setUrl(config.get(HttpOptions.URL)); httpRestConfig.setDecode(config.get(HttpOptions.DECODE)); httpRestConfig.setRequestMode(config.get(HttpOptions.METHOD)); + httpRestConfig.setDataSubject(config.get(HttpOptions.DATA_SUBJECT)); + httpRestConfig.setCycles(config.get(HttpOptions.CYCLES)); httpRestConfig.setParam( gson.fromJson( config.get(HttpOptions.PARAMS), diff --git a/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/table/HttpOptions.java b/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/table/HttpOptions.java index 81ea37ba0f..0bfaf10eb5 100644 --- a/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/table/HttpOptions.java +++ b/chunjun-connectors/chunjun-connector-http/src/main/java/com/dtstack/chunjun/connector/http/table/HttpOptions.java @@ -64,4 +64,16 @@ public class HttpOptions { public static final ConfigOption DELAY = ConfigOptions.key("delay").intType().defaultValue(30).withDescription("request delay"); + + public static final ConfigOption DATA_SUBJECT = + ConfigOptions.key("dataSubject") + .stringType() + .defaultValue("${data}") + .withDescription("response data subject"); + + public static final ConfigOption CYCLES = + ConfigOptions.key("cycles") + .longType() + .defaultValue(1L) + .withDescription("request cycle"); }