title: Phalcon Rest Api
body: <p>I'm trying to create Rest Api on Phalcon. The main question is - how to use BaseController in different controllers (it would be very conveniently get translations or info for logined user or check if user is logined in Base controller).</p>
  
  <p>When I do something like that</p>
  
  <pre><code>$posts = new Collection();
  $posts-&gt;setHandler(new PostController());
  $posts-&gt;setPrefix('/posts');
  $posts-&gt;get('/show/{id}', 'show');
  $app-&gt;mount($posts);
  
  $index = new Collection();
  $index-&gt;setHandler(new IndexController());
  $index-&gt;setPrefix('/index');
  $index-&gt;post('/someurl');
  $index-&gt;mount($index);
  </code></pre>
  
  <p>PostController and IndexController extend the BaseController. But when I get url(for example) "/index/someurl", I see that BaseController works twiсe. </p>
  
  <p>Is there some way to parse url before setHandler and make the Collection dependently on url and parameters? Or, maybe, there is another way to organize code. Thanks.</p>