14. What is RESTful Web Sevices?
• RESTful services was first introduced in the year 2000
by Roy Fielding at the university of California.
But RESTful was popular only the last few years.
• Many developers found SOAP hard to use.
For example, working with SOAP in JavaScript means writing
a ton of code to perform extremely simple tasks because you
must create the required XML structure absolutely every time.
• REST provides a lighter weight alternative. Instead of using XML
to make a request, REST relies on a simple URL in many cases.
15. • Resource based URIs
• HTTP methods
• HTTP status codes
• Message headers
What we need?
16. RESTful with Groovy on Grails
Different approaches
• Using just @Resource.
• With uri attribute.
• With explicit UrlMappings
• Using Controller
17. package com.grailsbaki
import grails.rest.Resource
@Resource
class Job {
String name
static constraints = {
}
}
package com.grailsbaki
import grails.rest.Resource
@Resource(uri=‘/category’)
class Category {
String name
static hasMany = [jobs: Job]
static constraints = {
}
}