Created
June 5, 2012 14:13
-
-
Save andersonfraga/2875251 to your computer and use it in GitHub Desktop.
Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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