Controller BeforeFilter #300

Open
celorodovalho opened this Issue Jan 17, 2013 · 3 comments

Comments

Projects
None yet
3 participants

How can I get all the URL that is passed through the application?
In CakePHP framework, I had only put a before-filter in AppController and capture the POST / GET / this.params
But i tried to do this in application.js and dont work.

Contributor

Techwraith commented Jan 17, 2013

You should have access to the request inside of your before filter:

this.request.url; // should be the requested URL

I need to get this before all actions of all controllers
I did:

var Application = function () {
    this.before(function(req, resp, params){
        console.log(this.request);
    });
};

This work before access any method, but when i try access a wrong url like "http://localhost:4000/controller/param-test", i have a error "/controller/param-test dont exist" but in console dont show any log.

Contributor

MiguelMadero commented Jan 18, 2013

The reason is that the router is handling this error. It realizes that
there's no controller action that matches that url, so it responds
directly.

I don't know were to intercept this errors. A (possibly bad) idea would be
to add a wildcard route at the end that catches everything that didn't
match. There might be a better solution though.

Miguel

On Fri, Jan 18, 2013 at 6:50 AM, celorodovalho notifications@github.comwrote:

I need to get this before all actions of all controllers
I did:

var Application = function () {
this.before(function(req, resp, params){
console.log(this.request);
});
};

This work before access any method, but when i try access a wrong url like
"http://localhost:4000/controller/param-test", i have a error
"/controller/param-test dont exist" but in console dont show any log.


Reply to this email directly or view it on GitHubhttps://github.com/mde/geddy/issues/300#issuecomment-12420412.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment