kubo/client/httpapi/request.go
Łukasz Magiera f34788e6ee cleanup Swarm.Peers
This commit was moved from ipfs/go-ipfs-http-client@fd7858dc57
2019-02-19 23:11:08 +01:00

35 lines
597 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
}
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),
}
}