Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
pkg/tool/http: make request.body optional
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
eonpatapon authored and mpvl committed May 13, 2021
1 parent dd188a6 commit 073c6aa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/tool/http/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/tool/http/http.cue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Do: {
url: string // TODO: make url.URL type

request: {
body: *bytes | string
body?: bytes | string
header: [string]: string | [...string]
trailer: [string]: string | [...string]
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/tool/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package http
//go:generate gofmt -s -w .

import (
"bytes"
"io"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -52,6 +53,8 @@ func (c *httpCmd) Run(ctx *task.Context) (res interface{}, err error) {
if err != nil {
return nil, err
}
} else {
r = bytes.NewReader([]byte(""))
}
if header, err = parseHeaders(obj, "header"); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/tool/http/pkg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 073c6aa

Please sign in to comment.