blob: d1c1560b52ae5051aa2edb5ede00d4b2445c4ccb [file] [log] [blame]
package example
import grails.gorm.transactions.ReadOnly
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
@RestController
class BookController {
@Autowired
BookService bookService
@RequestMapping("/book")
@ReadOnly
Book greeting(@RequestParam(required = false) String title) {
if(title) {
return bookService.find(title)
}
else {
return Book.first()
}
}
}