Refactor PostsController to have RESTful API