@Post("/products")
 public void create(Product product) {
   validator.validate(product);
   validator.onErrorUsePageOf(this).newProduct();
   repository.create(product);
   result.redirectTo(this).index();
 }
 @Put("/products")
 public void update(Product product) {
   validator.validate(product);
   validator.onErrorUsePageOf(this).edit(product);
   repository.update(product);
   result.redirectTo(this).index();
 }
 @Delete("/products/{product.id}")
 public void destroy(Product product) {
   repository.destroy(repository.find(product.getId()));
   result.redirectTo(this).index();
 }
 @Get("/products/{product.id}")
 public Product show(Product product) {
   product = repository.find(product.getId());
   result.include("json", json.toJson(product));
   return product;
 }
 @Get("/products")
 public List<Product> index() {
   List<Product> list = repository.findAll();
   result.include("json", json.toJson(list));
   return repository.findAll();
 }