提交 48bd73c5 作者: Matt Bell 提交者: Juan Batiz-Benet

commands/http: Made client load RPC host from config

上级 20f86c01
...@@ -6,14 +6,26 @@ import ( ...@@ -6,14 +6,26 @@ import (
"net/http" "net/http"
"strings" "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" cmds "github.com/jbenet/go-ipfs/commands"
) )
const ApiPath = "/api/v0" const ApiPath = "/api/v0"
func Send(req cmds.Request) (cmds.Response, error) { func Send(req cmds.Request) (cmds.Response, error) {
// TODO: load RPC host from config addr, err := ma.NewMultiaddr(req.Context().Config.Addresses.API)
url := "http://localhost:8080" + ApiPath 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(), "/") url += "/" + strings.Join(req.Path(), "/")
// TODO: support other encodings once we have multicodec to decode response // TODO: support other encodings once we have multicodec to decode response
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论