Created
October 8, 2012 09:13
-
-
Save partlyhuman/3851556 to your computer and use it in GitHub Desktop.
Quickie RESTful API tester for my sinatra app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just slapped this together, then even go one further and
alias GET='docurl.sh GET'