Skip to content

Commit

Permalink
Remove context-paths from example URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanernam committed Dec 18, 2015
1 parent 1324ec4 commit 6695fb5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/en/guide/scaffolding.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ With this configured, when you start your application the actions and views will
* save
* update

A CRUD interface will also be generated. To access this open @http://localhost:8080/app/book@ in a browser.
A CRUD interface will also be generated. To access this open @http://localhost:8080/book@ in a browser.

Note: The old alternative of defining @scaffold@ property:

Expand Down
2 changes: 1 addition & 1 deletion src/en/guide/theWebLayer/controllers/commandObjects.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Widget {
{code}

{code}
\$ curl -H "Content-Type: application/json" -d '{"name":"Some Widget","size":"42"}' localhost:8080/myapp/demo/createWidget
\$ curl -H "Content-Type: application/json" -d '{"name":"Some Widget","size":"42"}' localhost:8080/demo/createWidget
Name: Some Widget, Size: 42
~ \$
\$ curl -H "Content-Type: application/xml" -d '<widget><name>Some Other Widget</name><size>2112</size></widget>' localhost:8080/bodybind/demo/createWidget
Expand Down
12 changes: 6 additions & 6 deletions src/en/guide/webServices/REST/domainResources.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can try it out by adding some test data to @BootStrap.groovy@:
}
{code}

And then hitting the URL http://localhost:8080/myapp/books/1, which will render the response like:
And then hitting the URL http://localhost:8080/books/1, which will render the response like:

{code}
<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -35,7 +35,7 @@ And then hitting the URL http://localhost:8080/myapp/books/1, which will render
</book>
{code}

If you change the URL to @http://localhost:8080/myapp/books/1.json@ you will get a JSON response such as:
If you change the URL to @http://localhost:8080/books/1.json@ you will get a JSON response such as:


{code}
Expand Down Expand Up @@ -69,7 +69,7 @@ See the section on [Configuring Mime Types|guide:contentNegotiation] in the user
Instead of using the file extension in the URI, you can also obtain a JSON response using the ACCEPT header. Here's an example using the Unix @curl@ tool:

{code}
$ curl -i -H "Accept: application/json" localhost:8080/myapp/books/1
$ curl -i -H "Accept: application/json" localhost:8080/books/1
{"id":1,"title":"The Stand"}
{code}

Expand All @@ -78,7 +78,7 @@ This works thanks to Grails' [Content Negotiation|guide:contentNegotiation] feat
You can create a new resource by issuing a @POST@ request:

{code}
$ curl -i -X POST -H "Content-Type: application/json" -d '{"title":"Along Came A Spider"}' localhost:8080/myapp/books
$ curl -i -X POST -H "Content-Type: application/json" -d '{"title":"Along Came A Spider"}' localhost:8080/books
HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
...
Expand All @@ -87,7 +87,7 @@ Server: Apache-Coyote/1.1
Updating can be done with a @PUT@ request:

{code}
$ curl -i -X PUT -H "Content-Type: application/json" -d '{"title":"Along Came A Spider"}' localhost:8080/myapp/books/1
$ curl -i -X PUT -H "Content-Type: application/json" -d '{"title":"Along Came A Spider"}' localhost:8080/books/1
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
...
Expand All @@ -96,7 +96,7 @@ Server: Apache-Coyote/1.1
Finally a resource can be deleted with @DELETE@ request:

{code}
$ curl -i -X DELETE localhost:8080/myapp/books/1
$ curl -i -X DELETE localhost:8080/books/1
HTTP/1.1 204 No Content
Server: Apache-Coyote/1.1
...
Expand Down
32 changes: 16 additions & 16 deletions src/en/guide/webServices/REST/hypermedia/hal.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ beans = {
With the bean in place requesting the HAL content type will return HAL:

{code}
$ curl -i -H "Accept: application/hal+json" http://localhost:8080/myapp/books/1
$ curl -i -H "Accept: application/hal+json" http://localhost:8080/books/1

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Expand All @@ -66,7 +66,7 @@ Content-Type: application/hal+json;charset=ISO-8859-1
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books/1",
"href": "http://localhost:8080/books/1",
"hreflang": "en",
"type": "application/hal+json"
}
Expand Down Expand Up @@ -98,7 +98,7 @@ beans = {
With the bean in place requesting the HAL content type will return HAL:

{code}
$ curl -i -H "Accept: application/hal+json" http://localhost:8080/myapp/books
$ curl -i -H "Accept: application/hal+json" http://localhost:8080/books
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/hal+json;charset=UTF-8
Expand All @@ -108,7 +108,7 @@ Date: Thu, 17 Oct 2013 02:34:14 GMT
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books",
"href": "http://localhost:8080/books",
"hreflang": "en",
"type": "application/hal+json"
}
Expand All @@ -118,7 +118,7 @@ Date: Thu, 17 Oct 2013 02:34:14 GMT
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books/1",
"href": "http://localhost:8080/books/1",
"hreflang": "en",
"type": "application/hal+json"
}
Expand All @@ -128,7 +128,7 @@ Date: Thu, 17 Oct 2013 02:34:14 GMT
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books/2",
"href": "http://localhost:8080/books/2",
"hreflang": "en",
"type": "application/hal+json"
}
Expand All @@ -138,7 +138,7 @@ Date: Thu, 17 Oct 2013 02:34:14 GMT
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books/3",
"href": "http://localhost:8080/books/3",
"hreflang": "en",
"type": "application/hal+json"
}
Expand All @@ -164,7 +164,7 @@ beans = {
With that in place the rendered HAL will look like the following:

{code}
$ curl -i -H "Accept: application/hal+json" http://localhost:8080/myapp/books
$ curl -i -H "Accept: application/hal+json" http://localhost:8080/books
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/hal+json;charset=UTF-8
Expand All @@ -174,7 +174,7 @@ Date: Thu, 17 Oct 2013 02:34:14 GMT
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books",
"href": "http://localhost:8080/books",
"hreflang": "en",
"type": "application/hal+json"
}
Expand All @@ -184,7 +184,7 @@ Date: Thu, 17 Oct 2013 02:34:14 GMT
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books/1",
"href": "http://localhost:8080/books/1",
"hreflang": "en",
"type": "application/hal+json"
}
Expand All @@ -194,7 +194,7 @@ Date: Thu, 17 Oct 2013 02:34:14 GMT
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books/2",
"href": "http://localhost:8080/books/2",
"hreflang": "en",
"type": "application/hal+json"
}
Expand All @@ -204,7 +204,7 @@ Date: Thu, 17 Oct 2013 02:34:14 GMT
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books/3",
"href": "http://localhost:8080/books/3",
"hreflang": "en",
"type": "application/hal+json"
}
Expand Down Expand Up @@ -254,7 +254,7 @@ In the above example the first bean defines a HAL renderer for a single book ins
With this in place issuing a request for the new Mime Type returns the necessary HAL:

{code}
$ curl -i -H "Accept: application/vnd.books.org.book+json" http://localhost:8080/myapp/books/1
$ curl -i -H "Accept: application/vnd.books.org.book+json" http://localhost:8080/books/1

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Expand All @@ -264,7 +264,7 @@ Content-Type: application/vnd.books.org.book+json;charset=ISO-8859-1
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books/1",
"href": "http://localhost:8080/books/1",
"hreflang": "en",
"type": "application/vnd.books.org.book+json"
}
Expand Down Expand Up @@ -294,12 +294,12 @@ Which will result in output such as:
{
"_links": {
"self": {
"href": "http://localhost:8080/myapp/books/1",
"href": "http://localhost:8080/books/1",
"hreflang": "en",
"type": "application/vnd.books.org.book+json"
}
"publisher": {
"href": "http://localhost:8080/myapp/books/1/publisher",
"href": "http://localhost:8080/books/1/publisher",
"hreflang": "en"
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/en/guide/webServices/REST/hypermedia/vndError.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
By default when a validation error occurs when attempting to POST new resources then the errors object will be sent back allow with a 422 respond code:

{code}
$ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d "" http://localhost:8080/myapp/books
$ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d "" http://localhost:8080/books

HTTP/1.1 422 Unprocessable Entity
Server: Apache-Coyote/1.1
Expand All @@ -27,7 +27,7 @@ beans = {
Then if you alter the client request to accept Vnd.Error you get an appropriate response:

{code}
$ curl -i -H "Accept: application/vnd.error+json,application/json" -H "Content-Type: application/json" -X POST -d "" http://localhost:8080/myapp/books
$ curl -i -H "Accept: application/vnd.error+json,application/json" -H "Content-Type: application/json" -X POST -d "" http://localhost:8080/books
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/vnd.error+json;charset=ISO-8859-1
Expand Down
4 changes: 2 additions & 2 deletions src/en/guide/webServices/REST/versioningResources.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ As an alternative Grails supports the passing of an @Accept-Version@ header from
Then in the client simply pass which version you need using the @Accept-Version@ header:

{code}
$ curl -i -H "Accept-Version: 1.0" -X GET http://localhost:8080/myapp/books
$ curl -i -H "Accept-Version: 1.0" -X GET http://localhost:8080/books
{code}

h4. Versioning using Hypermedia / Mime Types
Expand Down Expand Up @@ -86,5 +86,5 @@ class BookController extends RestfulController {
Then using the @Accept@ header you can specify which version you need using the Mime Type:

{code}
$ curl -i -H "Accept: application/vnd.books.org.book+json;v=1.0" -X GET http://localhost:8080/myapp/books
$ curl -i -H "Accept: application/vnd.books.org.book+json;v=1.0" -X GET http://localhost:8080/books
{code}

0 comments on commit 6695fb5

Please sign in to comment.