Skip to content

Commit 073c6aa

Browse files
eonpataponmpvl
authored andcommitted
pkg/tool/http: make request.body optional
For simple GET requests this is quite weird to have to set: `request: body: ""` Change-Id: I41a86ba5a5ab2dd25dad792e2efa4b95b874e30f Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9722 Reviewed-by: CUE cueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent dd188a6 commit 073c6aa

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

pkg/tool/http/doc.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/tool/http/http.cue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Do: {
2626
url: string // TODO: make url.URL type
2727

2828
request: {
29-
body: *bytes | string
29+
body?: bytes | string
3030
header: [string]: string | [...string]
3131
trailer: [string]: string | [...string]
3232
}

pkg/tool/http/http.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package http
1818
//go:generate gofmt -s -w .
1919

2020
import (
21+
"bytes"
2122
"io"
2223
"io/ioutil"
2324
"net/http"
@@ -52,6 +53,8 @@ func (c *httpCmd) Run(ctx *task.Context) (res interface{}, err error) {
5253
if err != nil {
5354
return nil, err
5455
}
56+
} else {
57+
r = bytes.NewReader([]byte(""))
5558
}
5659
if header, err = parseHeaders(obj, "header"); err != nil {
5760
return nil, err

pkg/tool/http/pkg.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)