Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
5e5d534e
Commit
5e5d534e
authored
Nov 03, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/http: Refactored API to a Client object that takes a string address
parent
2a1116ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
commands/http/client.go
commands/http/client.go
+13
-13
No files found.
commands/http/client.go
View file @
5e5d534e
...
...
@@ -8,26 +8,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"
// TODO: make configurable
func
Send
(
req
cmds
.
Request
)
(
cmds
.
Response
,
error
)
{
addr
,
err
:=
ma
.
NewMultiaddr
(
req
.
Context
()
.
Config
.
Addresses
.
API
)
if
err
!=
nil
{
return
nil
,
err
}
// Client is the commands HTTP client interface.
type
Client
interface
{
Send
(
req
cmds
.
Request
)
(
cmds
.
Response
,
error
)
}
_
,
host
,
err
:=
manet
.
DialArgs
(
addr
)
if
err
!=
nil
{
return
nil
,
err
}
type
client
struct
{
serverAddress
string
}
func
NewClient
(
address
string
)
Client
{
return
&
client
{
address
}
}
url
:=
"http://"
+
host
+
ApiPath
func
(
c
*
client
)
Send
(
req
cmds
.
Request
)
(
cmds
.
Response
,
error
)
{
url
:=
"http://"
+
c
.
serverAddress
+
ApiPath
url
+=
"/"
+
strings
.
Join
(
req
.
Path
(),
"/"
)
var
userEncoding
string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment