kubo/client/httpapi/request.go
Łukasz Magiera 745bf92506 gofmt
This commit was moved from ipfs/go-ipfs-http-client@f3c2c35086
2019-02-18 17:32:40 +01:00

37 lines
681 B
Go

package httpapi
import (
"context"
"io"
"strings"
)
type Request struct {
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
}
func NewRequest(ctx context.Context, url, command string, args ...string) *Request {
if !strings.HasPrefix(url, "http") {
url = "http://" + url
}
opts := map[string]string{
"encoding": "json",
"stream-channels": "true",
}
return &Request{
ApiBase: url + "/api/v0",
Command: command,
Args: args,
Opts: opts,
Headers: make(map[string]string),
DrainOut: true,
}
}