Commit 48bd73c5 authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

commands/http: Made client load RPC host from config

parent 20f86c01
......@@ -6,14 +6,26 @@ import (
"net/http"
"strings"
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
manet "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr/net"
cmds "github.com/jbenet/go-ipfs/commands"
)
const ApiPath = "/api/v0"
func Send(req cmds.Request) (cmds.Response, error) {
// TODO: load RPC host from config
url := "http://localhost:8080" + ApiPath
addr, err := ma.NewMultiaddr(req.Context().Config.Addresses.API)
if err != nil {
return nil, err
}
_, host, err := manet.DialArgs(addr)
if err != nil {
return nil, err
}
url := "http://" + host + ApiPath
url += "/" + strings.Join(req.Path(), "/")
// TODO: support other encodings once we have multicodec to decode response
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment