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-unixfs
Commits
405cfd97
Commit
405cfd97
authored
Nov 02, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/http: Made parser/client handle variadic arguments
parent
2c8fc856
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
commands/http/client.go
commands/http/client.go
+8
-1
commands/http/parse.go
commands/http/parse.go
+6
-5
No files found.
commands/http/client.go
View file @
405cfd97
...
...
@@ -49,8 +49,15 @@ func Send(req cmds.Request) (cmds.Response, error) {
}
args
:=
req
.
Arguments
()
argDefs
:=
req
.
Command
()
.
Arguments
var
argDef
cmds
.
Argument
for
i
,
arg
:=
range
args
{
if
req
.
Command
()
.
Arguments
[
i
]
.
Type
==
cmds
.
ArgString
{
if
i
<
len
(
argDefs
)
{
argDef
=
argDefs
[
i
]
}
if
argDef
.
Type
==
cmds
.
ArgString
{
query
+=
"&arg="
+
arg
.
(
string
)
}
else
{
...
...
commands/http/parse.go
View file @
405cfd97
...
...
@@ -36,17 +36,18 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
// Note that the argument handling here is dumb, it does not do any error-checking.
// (Arguments are further processed when the request is passed to the command to run)
args
:=
make
([]
interface
{},
len
(
cmd
.
Arguments
))
for
i
,
arg
:=
range
cmd
.
Arguments
{
args
:=
make
([]
interface
{},
0
)
for
_
,
arg
:=
range
cmd
.
Arguments
{
if
arg
.
Type
==
cmds
.
ArgString
{
i
f
len
(
stringArgs
)
>
0
{
args
[
i
]
=
stringArgs
[
0
]
f
or
j
:=
0
;
len
(
stringArgs
)
>
0
&&
arg
.
Variadic
||
j
==
0
;
j
++
{
args
=
append
(
args
,
stringArgs
[
0
]
)
stringArgs
=
stringArgs
[
1
:
]
}
}
else
{
// TODO: create multipart streams for file args
args
[
i
]
=
r
.
Body
args
=
append
(
args
,
r
.
Body
)
}
}
...
...
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