Mislav Marohnić
74a39f3ed1
Turns out we do need explicit Content-Length for file uploads
...
This reverts commit 141388fd23 .
2020-06-10 18:18:49 +02:00
vilmibm
8263cd238b
linter appeasement
2020-06-10 11:05:21 -05:00
Nate Smith
bd7e6bf00c
Merge branch 'trunk' into api-raw-body
2020-06-10 11:00:59 -05:00
Nate Smith
096bf6bb79
Merge pull request #1115 from cli/api-errors
...
Print HTTP errors on stderr in `api` command
2020-06-10 10:35:04 -05:00
Mislav Marohnić
141388fd23
Turns out, Go will automatically set Content-Length
2020-06-10 16:29:50 +02:00
Mislav Marohnić
b329919b19
api command: support raw body passed in via --input <file>
...
This is to support file uploads or to pass in JSON bodies constructed
elsewhere.
2020-06-10 15:53:06 +02:00
Mislav Marohnić
4165793fae
Extract printing response headers, include status line
2020-06-08 15:39:35 +02:00
Mislav Marohnić
fd1e87beeb
Print response header keys in color too
2020-06-08 15:18:06 +02:00
Mislav Marohnić
5d5bd04102
💅 Extract parsing error response into its own function
2020-06-08 15:12:13 +02:00
Mislav Marohnić
d57b5171cf
Print HTTP errors on stderr in api command
...
Most API errors are present in the response body itself, which will be
sent to stdout normally, but if stdout is redirected somewhere (as it's
common with scripts), failed HTTP requests will likely sabotage the rest
of the script, but no useful info will be shown on stderr.
This makes it so all REST and GraphQL errors are always shown on stderr.
Additionally, this makes sure that the command exits with a nonzero
status on any GraphQL errors.
2020-06-05 18:24:24 +02:00
Mislav Marohnić
62549465a0
Display JSON in indented, colored format in api output
2020-06-05 17:43:07 +02:00
Mislav Marohnić
292b428465
Add test for showing response headers
2020-05-20 16:28:27 +02:00
Mislav Marohnić
bef62faaea
Make NewCmdApi testable
2020-05-20 15:21:35 +02:00
Mislav Marohnić
f58e0bf710
Add api tests
2020-05-20 15:21:32 +02:00
Mislav Marohnić
a7100b1fdd
Extract parseFields to a func
2020-05-20 15:21:31 +02:00
Mislav Marohnić
90fa193eaf
Promote api command to a pkg/cmd/api package
2020-05-20 15:21:31 +02:00