Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Last active September 29, 2022 00:41
Show Gist options
  • Save jhyland87/6780d87dd1fc89f3ae38cf450a08ed99 to your computer and use it in GitHub Desktop.
Save jhyland87/6780d87dd1fc89f3ae38cf450a08ed99 to your computer and use it in GitHub Desktop.
function curlcmd() {
method=${1:-GET}
method=$(echo $method | tr '[a-z]' '[A-Z]')
/usr/bin/curl -X ${method} -i --header 'Accept: application/json' ${@:2} && echo
}
alias cjpost="curlcmd post"
alias cjget="curlcmd get"
alias cjput="curlcmd put"
alias cjdel="curlcmd delete"
: <<'example_result'
$ cjget http://petstore.swagger.io/v2/pet/1
HTTP/1.1 200 OK
Date: Mon, 19 Sep 2016 16:12:51 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Headers: Content-Type, api_key, Authorization
Content-Type: application/json
Connection: close
Server: Jetty(9.2.9.v20150224)
{"id":1,"category":{"id":1,"name":"string"},"name":"foo","photoUrls":["string"],"tags":[{"id":0,"name":"string"}],"status":"bar"}
example_result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment