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-cmds
Commits
ec3bac92
Commit
ec3bac92
authored
Jan 06, 2015
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/http: client: Decode values into a new instance of the output type
parent
e5171bf1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
http/client.go
http/client.go
+6
-5
No files found.
http/client.go
View file @
ec3bac92
...
...
@@ -150,11 +150,11 @@ func getResponse(httpRes *http.Response, req cmds.Request) (cmds.Response, error
outChan
:=
make
(
chan
interface
{})
go
func
()
{
dec
:=
json
.
NewDecoder
(
httpRes
.
Body
)
outputType
:=
reflect
.
ValueOf
(
req
.
Command
()
.
Type
)
.
Type
()
v
:=
reflect
.
New
(
outputType
)
.
Interface
()
outputType
:=
reflect
.
TypeOf
(
req
.
Command
()
.
Type
)
for
{
err
:=
dec
.
Decode
(
&
v
)
v
:=
reflect
.
New
(
outputType
)
.
Interface
()
err
:=
dec
.
Decode
(
v
)
if
err
!=
nil
&&
err
!=
io
.
EOF
{
fmt
.
Println
(
err
.
Error
())
return
...
...
@@ -199,8 +199,9 @@ func getResponse(httpRes *http.Response, req cmds.Request) (cmds.Response, error
res
.
SetError
(
e
,
e
.
Code
)
}
else
{
v
:=
req
.
Command
()
.
Type
err
=
dec
.
Decode
(
&
v
)
outputType
:=
reflect
.
TypeOf
(
req
.
Command
()
.
Type
)
v
:=
reflect
.
New
(
outputType
)
.
Interface
()
err
=
dec
.
Decode
(
v
)
if
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
err
}
...
...
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