This commit was moved from ipfs/go-ipfs-http-client@f3c2c35086
This commit is contained in:
Łukasz Magiera 2019-02-18 17:32:40 +01:00
parent 3088776f81
commit 745bf92506
4 changed files with 23 additions and 23 deletions

View File

@ -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,
}
}

View File

@ -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

View File

@ -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,
}
}

View File

@ -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