mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-24 03:47:45 +08:00
commands/http: Refactored API to a Client object that takes a string address
This commit is contained in:
parent
f95476c19a
commit
283c175fc4
@ -6,6 +6,9 @@ import (
|
||||
"os"
|
||||
"runtime/pprof"
|
||||
|
||||
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"
|
||||
cmdsCli "github.com/jbenet/go-ipfs/commands/cli"
|
||||
cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
|
||||
@ -133,7 +136,21 @@ func callCommand(req cmds.Request, root *cmds.Command) cmds.Response {
|
||||
}
|
||||
|
||||
if (!found || !localBool) && daemon.Locked(req.Context().ConfigRoot) {
|
||||
res, err = cmdsHttp.Send(req)
|
||||
addr, err := ma.NewMultiaddr(req.Context().Config.Addresses.API)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
_, host, err := manet.DialArgs(addr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
client := cmdsHttp.NewClient(host)
|
||||
|
||||
res, err = client.Send(req)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user