mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-24 11:57:44 +08:00
parent
3088776f81
commit
745bf92506
@ -128,9 +128,9 @@ func (api *HttpApi) WithOptions(opts ...caopts.ApiOption) (iface.CoreAPI, error)
|
||||
|
||||
func (api *HttpApi) request(command string, args ...string) *RequestBuilder {
|
||||
return &RequestBuilder{
|
||||
command: command,
|
||||
args: args,
|
||||
shell: api,
|
||||
command: command,
|
||||
args: args,
|
||||
shell: api,
|
||||
drainOut: true,
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ func (api *PubsubAPI) Publish(ctx context.Context, topic string, message []byte)
|
||||
type pubsubSub struct {
|
||||
messages chan pubsubMessage
|
||||
|
||||
done chan struct{}
|
||||
done chan struct{}
|
||||
rcloser io.Closer
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ type pubsubMessage struct {
|
||||
JTopicIDs []string `json:"topicIDs,omitempty"`
|
||||
|
||||
from peer.ID
|
||||
err error
|
||||
err error
|
||||
}
|
||||
|
||||
func (msg *pubsubMessage) From() peer.ID {
|
||||
@ -124,7 +124,7 @@ func (api *PubsubAPI) Subscribe(ctx context.Context, topic string, opts ...caopt
|
||||
|
||||
sub := &pubsubSub{
|
||||
messages: make(chan pubsubMessage),
|
||||
done: make(chan struct{}),
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
|
||||
dec := json.NewDecoder(resp.Output)
|
||||
@ -154,7 +154,7 @@ func (api *PubsubAPI) Subscribe(ctx context.Context, topic string, opts ...caopt
|
||||
return sub, nil
|
||||
}
|
||||
|
||||
func (s*pubsubSub) Close() error {
|
||||
func (s *pubsubSub) Close() error {
|
||||
if s.done != nil {
|
||||
close(s.done)
|
||||
s.done = nil
|
||||
|
||||
@ -7,12 +7,12 @@ import (
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
ApiBase string
|
||||
Command string
|
||||
Args []string
|
||||
Opts map[string]string
|
||||
Body io.Reader
|
||||
Headers map[string]string
|
||||
ApiBase string
|
||||
Command string
|
||||
Args []string
|
||||
Opts map[string]string
|
||||
Body io.Reader
|
||||
Headers map[string]string
|
||||
DrainOut bool // if set, resp.Close will read all remaining data
|
||||
}
|
||||
|
||||
@ -26,11 +26,11 @@ func NewRequest(ctx context.Context, url, command string, args ...string) *Reque
|
||||
"stream-channels": "true",
|
||||
}
|
||||
return &Request{
|
||||
ApiBase: url + "/api/v0",
|
||||
Command: command,
|
||||
Args: args,
|
||||
Opts: opts,
|
||||
Headers: make(map[string]string),
|
||||
ApiBase: url + "/api/v0",
|
||||
Command: command,
|
||||
Args: args,
|
||||
Opts: opts,
|
||||
Headers: make(map[string]string),
|
||||
DrainOut: true,
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,11 +14,11 @@ import (
|
||||
|
||||
// RequestBuilder is an IPFS commands request builder.
|
||||
type RequestBuilder struct {
|
||||
command string
|
||||
args []string
|
||||
opts map[string]string
|
||||
headers map[string]string
|
||||
body io.Reader
|
||||
command string
|
||||
args []string
|
||||
opts map[string]string
|
||||
headers map[string]string
|
||||
body io.Reader
|
||||
drainOut bool
|
||||
|
||||
shell *HttpApi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user