Skip to content

Instantly share code, notes, and snippets.

@andersonfraga
Created June 5, 2012 14:13
Show Gist options
  • Save andersonfraga/2875251 to your computer and use it in GitHub Desktop.
Save andersonfraga/2875251 to your computer and use it in GitHub Desktop.
Controller
class NewsController {
@Inject
private News news;
@Inject
private Author authors;
array respond_to() {
return [
'format' : ['html', 'xml', 'json'],
'only' : [
'json' : ['get_autores']
]
];
}
// @GET /news
@Cache(expires="1 hour")
array get() {
return news.list();
}
// @GET /news/123
@Cache(expires="tomorrow")
array get(int id) {
return news.findById(id);
}
// @POST /news
@Cache(no_cache)
array post() {
return news.create(params['news']);
}
// @GET /news/2312/autores
@Cache(expires="tomorrow")
array get_autores(int id) {
return authors.findByNews(id)
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment