Skip to content

Instantly share code, notes, and snippets.

@partlyhuman
Created October 8, 2012 09:13
Show Gist options
  • Save partlyhuman/3851556 to your computer and use it in GitHub Desktop.
Save partlyhuman/3851556 to your computer and use it in GitHub Desktop.
Quickie RESTful API tester for my sinatra app
#!/bin/bash
if [ $# -lt 2 ]; then
echo "USAGE: $0 [METHOD] [/path/to/endpoint] -d [key=value] "
exit 1
fi
COOKIES=.cookies
# JSONLINTER='python -mjson.tool'
JSONLINTER=jsonpretty # gem install jsonpretty
SERVER=http://localhost:3000
METHOD=$1
ENDPOINT=$2
shift 2
# Verbose and raw
# env curl -v -b $COOKIES -c $COOKIES -X $METHOD $SERVER$ENDPOINT $@
# Assume RESTful JSON endpoint and prettify result
env curl -s -b $COOKIES -c $COOKIES -X $METHOD $SERVER$ENDPOINT $@ | $JSONLINTER
@partlyhuman
Copy link
Author

I just slapped this together, then even go one further and
alias GET='docurl.sh GET'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment