mercredi 9 décembre 2015

Execute code before reaching the controller's code

My intention it's to create a MasterController that decides what configurations will use depending on the URL parameters.

  1. My first idea was to create a MasterController. All requests to the server would be redirected to this controller and then, this MasterController would decide wich controller to use, and redirect to it. The problem would be that this would make too many requests.

  2. My second idea was to call a function in the beginning of each controller that redirects to the correct controller if necessary. The problem would be the same: it would increase the number of requests.

Concrete example: Imagine that I have the followings URLs:

http:\\myapp.com\?showController1=true

http:\\myapp.com\abcd?showController1=true

When the server receives the request, I want the final result be the same: show Controller1, independently of the request being to homeController or abcdController.

To make this work, before witch controller is reached, I need to decide which controller will be called dependedind on the url parameters. But I want to minimize the number of requests made between the server and the browser.

It is possible to implement this without making extra requests?

Aucun commentaire:

Enregistrer un commentaire