Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Creating REST controllers and routes

Project Wonder contains a framework called ERRest, which follow the same patterns as Ruby on Rails REST concepts. Using REST-style URLs is perfect for building a public blog and to create REST services to manage posting over HTTP with JSON, XML or other formats.

By default, a REST route in ERRest will generate a link like this:

Code Block
/cgi-bin/WebObjects/AppName.woa/ra/EntityName/id

So for our case, to get the first blog posting from BlogRest, the URL will look like this:

Code Block
/cgi-bin/WebObjects/BlogRest.woa/ra/blogEntries/1.html
Info

You can shorten the URL by using mod_rewrite in Apache httpd

.

Creating controllers

ERRest needs controllers to act as a broker between working with the objects and the routes. So let's create a controller for BlogEntry.

Adding the routes

Adding posts and authors with curl

Adding HTML views for blog posts