如何更改 Kafka Rest Proxy CURL 命令以便在浏览器中使用它

How to change Kafka Rest Proxy CURL command in order to use it in a browser

我正在 Kafka 中试用 Rest Proxy。

当我在浏览器中输入以下内容时 url http://192.168.0.30:8082/topics,

我得到了预期的结果:

["__confluent.support.metrics","_confluent-command","_confluent-controlcenter-5-
2-2-1-MetricsAggregateStore-changelog","_confluent-controlcenter-5-2-2-1-actual-
group-consumption-rekey","_confluent-controlcenter-5-2-2-1-expected-group-
consumption-rekey","_confluent-controlcenter-5-2-2-1-metrics-trigger-measurement-
rekey","_confluent-ksql-default__command_topic","_confluent-metrics","_confluent-
monitoring","_schemas","connect-configs","connect-offsets","connect-
statuses","default_ksql_processing_log","test","test1"]


我的问题:我尽量不使用CURL。我有以下 CURL 命令示例。如果我只想像上面那样使用我的浏览器,我该如何更改它?

我试过了,但是...(我如何使用我的主题 test?)

**只是文档中的示例:**

# Create a consumer for binary data, starting at the beginning of the topic's
# log. Then consume some data from a topic.
$ curl -X POST -H "Content-Type: application/vnd.kafka.v1+json" \
      --data '{"id": "my_instance", "format": "binary", "auto.offset.reset": "smallest"}' \
      http://localhost:8082/consumers/my_binary_consumer
  {"instance_id":"my_instance","base_uri":"http://localhost:8082/consumers/my_binar
y_consumer/instances/my_instance"}

$ curl -X GET -H "Accept: application/vnd.kafka.binary.v1+json" \
      http://localhost:8082/consumers/my_binary_consumer/instances/my_instance/topics/test
  [{"key":null,"value":"S2Fma2E=","partition":0,"offset":0}]

浏览器只能发出 GET 请求。

您可以使用 Postman 或 Insomnia 等工具来发出其他 HTTP 请求。

(供进一步参考)

为了给 Kafka 使用 REST 代理,我使用了 Postman。

1. 我订阅了一个主题 test.

$ curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data 
'{"topics":["test"]}' \   
http://192.168.0.30:8082/consumers/my_json_consumer/instances/my_consumer_instanc
e/subscription

(我更改了此 CURL 以适合 Postman。)




2. 然后,我消耗了这个话题。

$ curl -X GET -H "Accept: application/vnd.kafka.json.v2+json" \
http://192.168.0.30:8082/consumers/my_json_consumer/instances/my_consumer_instanc
e/records

(我更改了此 CURL 以适合 Postman。)