Sure :)
But first i recommend u to see the examples (toturials)... and pick the right module/micro part (see https://github.com/phalcon/mvc ).
So, lets explain case when we use request to get which type we must return. It is pretty simple. U need to use request... by example:
(this is action in controller)
$this->request->isAjax()
- will check if request is ajax and then u can return json (for example). You can use functions like isDelete, isPut, isPost, isOptions. For more details visit: https://docs.phalcon.io/en/latest/reference/request.html ..thats all :)
The second case.. or what kind of data will return based by router its simple too - maybe in router params is our need - check if params is .json and return it.
https://docs.phalcon.io/en/latest/reference/routing.html - routing documentation.
And the last- how to return HTML or JSON (example)
function someAction()
{
// logick
// Something we need
$content = new stdClass;
$content->some = true;
// If ajax so return JSON
if ($this->request->isAjax()) {
$this->view->disable();
return $this->response->setJsonContent($content);
}
$this->view->content = $content;
}
But there are so many methodologies.
Check these resources : https://phalconist.com/search?q=rest
And last... sorry for my english :/
Good luck :)