Commit 69da9b6d authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

commands/http: Cleaner URL formation in client

parent e4b7bf7c
...@@ -11,7 +11,10 @@ import ( ...@@ -11,7 +11,10 @@ import (
cmds "github.com/jbenet/go-ipfs/commands" cmds "github.com/jbenet/go-ipfs/commands"
) )
const ApiPath = "/api/v0" // TODO: make configurable const (
ApiUrlFormat = "http://%s%s/%s"
ApiPath = "/api/v0" // TODO: make configurable
)
// Client is the commands HTTP client interface. // Client is the commands HTTP client interface.
type Client interface { type Client interface {
...@@ -27,8 +30,8 @@ func NewClient(address string) Client { ...@@ -27,8 +30,8 @@ func NewClient(address string) Client {
} }
func (c *client) Send(req cmds.Request) (cmds.Response, error) { func (c *client) Send(req cmds.Request) (cmds.Response, error) {
url := "http://" + c.serverAddress + ApiPath path := strings.Join(req.Path(), "/")
url += "/" + strings.Join(req.Path(), "/") url := fmt.Sprintf(ApiUrlFormat, c.serverAddress, ApiPath, path)
var userEncoding string var userEncoding string
if enc, found := req.Option(cmds.EncShort); found { if enc, found := req.Option(cmds.EncShort); found {
......
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