Skip to content

Commit 09f449b

Browse files
fix: use nil instead of empty string as request body (streamnative#662)
Signed-off-by: Zixuan Liu <[email protected]> Co-authored-by: lipenghui <[email protected]>
1 parent 06d64a7 commit 09f449b

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

pkg/pulsar/functions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,14 @@ func (f *functions) CreateFuncWithURL(funcConf *utils.FunctionConfig, pkgURL str
266266

267267
func (f *functions) StopFunction(tenant, namespace, name string) error {
268268
endpoint := f.pulsar.endpoint(f.basePath, tenant, namespace, name)
269-
return f.pulsar.Client.Post(endpoint+"/stop", "")
269+
return f.pulsar.Client.Post(endpoint+"/stop", nil)
270270
}
271271

272272
func (f *functions) StopFunctionWithID(tenant, namespace, name string, instanceID int) error {
273273
id := fmt.Sprintf("%d", instanceID)
274274
endpoint := f.pulsar.endpoint(f.basePath, tenant, namespace, name, id)
275275

276-
return f.pulsar.Client.Post(endpoint+"/stop", "")
276+
return f.pulsar.Client.Post(endpoint+"/stop", nil)
277277
}
278278

279279
func (f *functions) DeleteFunction(tenant, namespace, name string) error {
@@ -329,26 +329,26 @@ func (f *functions) DownloadFunctionByNs(destinationFile, tenant, namespace, fun
329329

330330
func (f *functions) StartFunction(tenant, namespace, name string) error {
331331
endpoint := f.pulsar.endpoint(f.basePath, tenant, namespace, name)
332-
return f.pulsar.Client.Post(endpoint+"/start", "")
332+
return f.pulsar.Client.Post(endpoint+"/start", nil)
333333
}
334334

335335
func (f *functions) StartFunctionWithID(tenant, namespace, name string, instanceID int) error {
336336
id := fmt.Sprintf("%d", instanceID)
337337
endpoint := f.pulsar.endpoint(f.basePath, tenant, namespace, name, id)
338338

339-
return f.pulsar.Client.Post(endpoint+"/start", "")
339+
return f.pulsar.Client.Post(endpoint+"/start", nil)
340340
}
341341

342342
func (f *functions) RestartFunction(tenant, namespace, name string) error {
343343
endpoint := f.pulsar.endpoint(f.basePath, tenant, namespace, name)
344-
return f.pulsar.Client.Post(endpoint+"/restart", "")
344+
return f.pulsar.Client.Post(endpoint+"/restart", nil)
345345
}
346346

347347
func (f *functions) RestartFunctionWithID(tenant, namespace, name string, instanceID int) error {
348348
id := fmt.Sprintf("%d", instanceID)
349349
endpoint := f.pulsar.endpoint(f.basePath, tenant, namespace, name, id)
350350

351-
return f.pulsar.Client.Post(endpoint+"/restart", "")
351+
return f.pulsar.Client.Post(endpoint+"/restart", nil)
352352
}
353353

354354
func (f *functions) GetFunctions(tenant, namespace string) ([]string, error) {

pkg/pulsar/namespace.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ func (n *namespaces) Unload(namespace string) error {
678678
return err
679679
}
680680
endpoint := n.pulsar.endpoint(n.basePath, nsName.String(), "unload")
681-
return n.pulsar.Client.Put(endpoint, "")
681+
return n.pulsar.Client.Put(endpoint, nil)
682682
}
683683

684684
func (n *namespaces) UnloadNamespaceBundle(namespace, bundle string) error {
@@ -687,7 +687,7 @@ func (n *namespaces) UnloadNamespaceBundle(namespace, bundle string) error {
687687
return err
688688
}
689689
endpoint := n.pulsar.endpoint(n.basePath, nsName.String(), bundle, "unload")
690-
return n.pulsar.Client.Put(endpoint, "")
690+
return n.pulsar.Client.Put(endpoint, nil)
691691
}
692692

693693
func (n *namespaces) SplitNamespaceBundle(namespace, bundle string, unloadSplitBundles bool) error {
@@ -699,7 +699,7 @@ func (n *namespaces) SplitNamespaceBundle(namespace, bundle string, unloadSplitB
699699
params := map[string]string{
700700
"unload": strconv.FormatBool(unloadSplitBundles),
701701
}
702-
return n.pulsar.Client.PutWithQueryParams(endpoint, "", nil, params)
702+
return n.pulsar.Client.PutWithQueryParams(endpoint, nil, nil, params)
703703
}
704704

705705
func (n *namespaces) GetNamespacePermissions(namespace utils.NameSpaceName) (map[string][]common.AuthAction, error) {
@@ -748,33 +748,33 @@ func (n *namespaces) SetEncryptionRequiredStatus(namespace utils.NameSpaceName,
748748

749749
func (n *namespaces) UnsubscribeNamespace(namespace utils.NameSpaceName, sName string) error {
750750
endpoint := n.pulsar.endpoint(n.basePath, namespace.String(), "unsubscribe", url.QueryEscape(sName))
751-
return n.pulsar.Client.Post(endpoint, "")
751+
return n.pulsar.Client.Post(endpoint, nil)
752752
}
753753

754754
func (n *namespaces) UnsubscribeNamespaceBundle(namespace utils.NameSpaceName, bundle, sName string) error {
755755
endpoint := n.pulsar.endpoint(n.basePath, namespace.String(), bundle, "unsubscribe", url.QueryEscape(sName))
756-
return n.pulsar.Client.Post(endpoint, "")
756+
return n.pulsar.Client.Post(endpoint, nil)
757757
}
758758

759759
func (n *namespaces) ClearNamespaceBundleBacklogForSubscription(namespace utils.NameSpaceName,
760760
bundle, sName string) error {
761761
endpoint := n.pulsar.endpoint(n.basePath, namespace.String(), bundle, "clearBacklog", url.QueryEscape(sName))
762-
return n.pulsar.Client.Post(endpoint, "")
762+
return n.pulsar.Client.Post(endpoint, nil)
763763
}
764764

765765
func (n *namespaces) ClearNamespaceBundleBacklog(namespace utils.NameSpaceName, bundle string) error {
766766
endpoint := n.pulsar.endpoint(n.basePath, namespace.String(), bundle, "clearBacklog")
767-
return n.pulsar.Client.Post(endpoint, "")
767+
return n.pulsar.Client.Post(endpoint, nil)
768768
}
769769

770770
func (n *namespaces) ClearNamespaceBacklogForSubscription(namespace utils.NameSpaceName, sName string) error {
771771
endpoint := n.pulsar.endpoint(n.basePath, namespace.String(), "clearBacklog", url.QueryEscape(sName))
772-
return n.pulsar.Client.Post(endpoint, "")
772+
return n.pulsar.Client.Post(endpoint, nil)
773773
}
774774

775775
func (n *namespaces) ClearNamespaceBacklog(namespace utils.NameSpaceName) error {
776776
endpoint := n.pulsar.endpoint(n.basePath, namespace.String(), "clearBacklog")
777-
return n.pulsar.Client.Post(endpoint, "")
777+
return n.pulsar.Client.Post(endpoint, nil)
778778
}
779779

780780
func (n *namespaces) SetReplicatorDispatchRate(namespace utils.NameSpaceName, rate utils.DispatchRate) error {

pkg/pulsar/sinks.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,38 +390,38 @@ func (s *sinks) GetSinkStatusWithID(tenant, namespace, sink string, id int) (uti
390390

391391
func (s *sinks) RestartSink(tenant, namespace, sink string) error {
392392
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, sink)
393-
return s.pulsar.Client.Post(endpoint+"/restart", "")
393+
return s.pulsar.Client.Post(endpoint+"/restart", nil)
394394
}
395395

396396
func (s *sinks) RestartSinkWithID(tenant, namespace, sink string, instanceID int) error {
397397
id := fmt.Sprintf("%d", instanceID)
398398
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, sink, id)
399399

400-
return s.pulsar.Client.Post(endpoint+"/restart", "")
400+
return s.pulsar.Client.Post(endpoint+"/restart", nil)
401401
}
402402

403403
func (s *sinks) StopSink(tenant, namespace, sink string) error {
404404
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, sink)
405-
return s.pulsar.Client.Post(endpoint+"/stop", "")
405+
return s.pulsar.Client.Post(endpoint+"/stop", nil)
406406
}
407407

408408
func (s *sinks) StopSinkWithID(tenant, namespace, sink string, instanceID int) error {
409409
id := fmt.Sprintf("%d", instanceID)
410410
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, sink, id)
411411

412-
return s.pulsar.Client.Post(endpoint+"/stop", "")
412+
return s.pulsar.Client.Post(endpoint+"/stop", nil)
413413
}
414414

415415
func (s *sinks) StartSink(tenant, namespace, sink string) error {
416416
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, sink)
417-
return s.pulsar.Client.Post(endpoint+"/start", "")
417+
return s.pulsar.Client.Post(endpoint+"/start", nil)
418418
}
419419

420420
func (s *sinks) StartSinkWithID(tenant, namespace, sink string, instanceID int) error {
421421
id := fmt.Sprintf("%d", instanceID)
422422
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, sink, id)
423423

424-
return s.pulsar.Client.Post(endpoint+"/start", "")
424+
return s.pulsar.Client.Post(endpoint+"/start", nil)
425425
}
426426

427427
func (s *sinks) GetBuiltInSinks() ([]*utils.ConnectorDefinition, error) {
@@ -433,5 +433,5 @@ func (s *sinks) GetBuiltInSinks() ([]*utils.ConnectorDefinition, error) {
433433

434434
func (s *sinks) ReloadBuiltInSinks() error {
435435
endpoint := s.pulsar.endpoint(s.basePath, "reloadBuiltInSinks")
436-
return s.pulsar.Client.Post(endpoint, "")
436+
return s.pulsar.Client.Post(endpoint, nil)
437437
}

pkg/pulsar/sources.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,38 +393,38 @@ func (s *sources) GetSourceStatusWithID(tenant, namespace, source string, id int
393393

394394
func (s *sources) RestartSource(tenant, namespace, source string) error {
395395
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, source)
396-
return s.pulsar.Client.Post(endpoint+"/restart", "")
396+
return s.pulsar.Client.Post(endpoint+"/restart", nil)
397397
}
398398

399399
func (s *sources) RestartSourceWithID(tenant, namespace, source string, instanceID int) error {
400400
id := fmt.Sprintf("%d", instanceID)
401401
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, source, id)
402402

403-
return s.pulsar.Client.Post(endpoint+"/restart", "")
403+
return s.pulsar.Client.Post(endpoint+"/restart", nil)
404404
}
405405

406406
func (s *sources) StopSource(tenant, namespace, source string) error {
407407
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, source)
408-
return s.pulsar.Client.Post(endpoint+"/stop", "")
408+
return s.pulsar.Client.Post(endpoint+"/stop", nil)
409409
}
410410

411411
func (s *sources) StopSourceWithID(tenant, namespace, source string, instanceID int) error {
412412
id := fmt.Sprintf("%d", instanceID)
413413
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, source, id)
414414

415-
return s.pulsar.Client.Post(endpoint+"/stop", "")
415+
return s.pulsar.Client.Post(endpoint+"/stop", nil)
416416
}
417417

418418
func (s *sources) StartSource(tenant, namespace, source string) error {
419419
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, source)
420-
return s.pulsar.Client.Post(endpoint+"/start", "")
420+
return s.pulsar.Client.Post(endpoint+"/start", nil)
421421
}
422422

423423
func (s *sources) StartSourceWithID(tenant, namespace, source string, instanceID int) error {
424424
id := fmt.Sprintf("%d", instanceID)
425425
endpoint := s.pulsar.endpoint(s.basePath, tenant, namespace, source, id)
426426

427-
return s.pulsar.Client.Post(endpoint+"/start", "")
427+
return s.pulsar.Client.Post(endpoint+"/start", nil)
428428
}
429429

430430
func (s *sources) GetBuiltInSources() ([]*utils.ConnectorDefinition, error) {
@@ -436,5 +436,5 @@ func (s *sources) GetBuiltInSources() ([]*utils.ConnectorDefinition, error) {
436436

437437
func (s *sources) ReloadBuiltInSources() error {
438438
endpoint := s.pulsar.endpoint(s.basePath, "reloadBuiltInSources")
439-
return s.pulsar.Client.Post(endpoint, "")
439+
return s.pulsar.Client.Post(endpoint, nil)
440440
}

pkg/pulsar/subscription.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,34 +111,34 @@ func (s *subscriptions) ResetCursorToTimestamp(topic utils.TopicName, sName stri
111111
endpoint := s.pulsar.endpoint(
112112
s.basePath, topic.GetRestPath(), s.SubPath, url.PathEscape(sName),
113113
"resetcursor", strconv.FormatInt(timestamp, 10))
114-
return s.pulsar.Client.Post(endpoint, "")
114+
return s.pulsar.Client.Post(endpoint, nil)
115115
}
116116

117117
func (s *subscriptions) ClearBacklog(topic utils.TopicName, sName string) error {
118118
endpoint := s.pulsar.endpoint(
119119
s.basePath, topic.GetRestPath(), s.SubPath, url.PathEscape(sName), "skip_all")
120-
return s.pulsar.Client.Post(endpoint, "")
120+
return s.pulsar.Client.Post(endpoint, nil)
121121
}
122122

123123
func (s *subscriptions) SkipMessages(topic utils.TopicName, sName string, n int64) error {
124124
endpoint := s.pulsar.endpoint(
125125
s.basePath, topic.GetRestPath(), s.SubPath, url.PathEscape(sName),
126126
"skip", strconv.FormatInt(n, 10))
127-
return s.pulsar.Client.Post(endpoint, "")
127+
return s.pulsar.Client.Post(endpoint, nil)
128128
}
129129

130130
func (s *subscriptions) ExpireMessages(topic utils.TopicName, sName string, expire int64) error {
131131
endpoint := s.pulsar.endpoint(
132132
s.basePath, topic.GetRestPath(), s.SubPath, url.PathEscape(sName),
133133
"expireMessages", strconv.FormatInt(expire, 10))
134-
return s.pulsar.Client.Post(endpoint, "")
134+
return s.pulsar.Client.Post(endpoint, nil)
135135
}
136136

137137
func (s *subscriptions) ExpireAllMessages(topic utils.TopicName, expire int64) error {
138138
endpoint := s.pulsar.endpoint(
139139
s.basePath, topic.GetRestPath(), "all_subscription",
140140
"expireMessages", strconv.FormatInt(expire, 10))
141-
return s.pulsar.Client.Post(endpoint, "")
141+
return s.pulsar.Client.Post(endpoint, nil)
142142
}
143143

144144
func (s *subscriptions) PeekMessages(topic utils.TopicName, sName string, n int) ([]*utils.Message, error) {

pkg/pulsar/topic.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func (t *topics) GetPartitionedStats(topic utils.TopicName, perPartition bool) (
401401
func (t *topics) Terminate(topic utils.TopicName) (utils.MessageID, error) {
402402
endpoint := t.pulsar.endpoint(t.basePath, topic.GetRestPath(), "terminate")
403403
var messageID utils.MessageID
404-
err := t.pulsar.Client.PostWithObj(endpoint, "", &messageID)
404+
err := t.pulsar.Client.PostWithObj(endpoint, nil, &messageID)
405405
return messageID, err
406406
}
407407

@@ -419,12 +419,12 @@ func (t *topics) OffloadStatus(topic utils.TopicName) (utils.OffloadProcessStatu
419419

420420
func (t *topics) Unload(topic utils.TopicName) error {
421421
endpoint := t.pulsar.endpoint(t.basePath, topic.GetRestPath(), "unload")
422-
return t.pulsar.Client.Put(endpoint, "")
422+
return t.pulsar.Client.Put(endpoint, nil)
423423
}
424424

425425
func (t *topics) Compact(topic utils.TopicName) error {
426426
endpoint := t.pulsar.endpoint(t.basePath, topic.GetRestPath(), "compaction")
427-
return t.pulsar.Client.Put(endpoint, "")
427+
return t.pulsar.Client.Put(endpoint, nil)
428428
}
429429

430430
func (t *topics) CompactStatus(topic utils.TopicName) (utils.LongRunningProcessStatus, error) {

0 commit comments

Comments
 (0)