Skip to content

Instantly share code, notes, and snippets.

@jbrisbin
Created October 22, 2012 15:54
Show Gist options
  • Save jbrisbin/3932201 to your computer and use it in GitHub Desktop.
Save jbrisbin/3932201 to your computer and use it in GitHub Desktop.
Sample REST shell interaction
> JAVA_OPTS="-DbaseUri=http://localhost:8080/exporter" rest-shell
___ ___ __ _____ __ _ _ _ _ __
| _ \ __/' _/_ _/' _/| || | / / | \ \
| v / _|`._`. | | `._`.| >< | / / / > >
|_|_\___|___/ |_| |___/|_||_| |_/_/ /_/
Welcome to the REST shell. For assistance hit TAB or type "help".
http://localhost:8080:> discover #{env.baseUri}
rel href
=================================================================
family http://localhost:8080/exporter/family
peeps http://localhost:8080/exporter/people
http://localhost:8080/exporter:> get --rel p<TAB>
peeps profile
http://localhost:8080/exporter:> get --rel peeps
> GET http://localhost:8080/exporter/people
< 200 OK
< Content-Length: 3849
< Content-Type: application/json
<
{
...
}
http://localhost:8080/exporter:> var list
{
"responseBody" : {
...
},
"links" : {
"links" : [ {
"rel" : "peeps.search",
"href" : "http://localhost:8080/exporter/people/search"
} ]
},
"responseHeaders" : {
"Content-Length" : [ "3849" ],
"Content-Type" : [ "application/json" ],
},
"requestUrl" : "http://localhost:8080/exporter/people"
}
http://localhost:8080/exporter:> post people --data "{name: 'John Doe'}" --follow true
> POST http://localhost:8080/exporter/people
< 201 CREATED
< Location: http://localhost:8080/exporter/people/9
<
http://localhost:8080/exporter/people/9:> list
rel href
===========================================================================
self http://localhost:8080/exporter/people/9
peeps.Person.profiles http://localhost:8080/exporter/people/9/profiles
peeps.Person.addresses http://localhost:8080/exporter/people/9/addresses
added-link http://localhost:8080/people
http://localhost:8080/exporter/people/9:> var get --value #{links["peeps.search"]}
{ rel : peeps.search, href : http://localhost:8080/exporter/people/search }
http://localhost:8080/exporter/people/9:> list #{links["peeps.search"].href}
rel href
===================================================================================
peeps.id http://localhost:8080/exporter/people/search/id
peeps.created http://localhost:8080/exporter/people/search/created
peeps.count http://localhost:8080/exporter/people/search/count
peeps.names http://localhost:8080/exporter/people/search/name
peeps.nameStartsWith http://localhost:8080/exporter/people/search/nameStartsWith
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment