[Catalyst] Question about Chained Controller
Ben van Staveren
benvanstaveren at gmail.com
Tue Nov 16 17:28:30 GMT 2010
> Charlie> I use a :AuthRequired method attribute and check for that
> Charlie> in auto method. Is there anything inherently wrong with
> Charlie> that method? I got the technique from someone on this list
> Charlie> a while back.
>
> When your requirements pile up, auto is going to become a big block of
> monolithic code, and your methods are going to have enormous sequences of
> attributes. Plus, I find it more logical to have the checking code
> closer to where it's required, as opposed to having to maintain the
> attributes scattered around the app then locate and edit the related
> code in auto.
>
Depending on how much of your app is authentication-protected, you could
reverse the idea; auth is checked unless an attribute :NoAuth is set. I
found that if you have a Root controller that contains an index method
that forwards to the proper place, a default method that generates your
404 or forwards, and an auto method that deals with the "global" setup,
things make a bit more sense. Optionally you can always put all your
auth bits in one module, and use it from the Root controller and use the
auto in Root to run your module against the current request and give the
go-ahead.
Many ways to prevent your Root controller from becoming one bigass piece
of spaghetti :)
Just my 2 cents
--
Ben van Staveren
phone: +62 81 70777529
email: benvanstaveren at gmail.com
More information about the Catalyst
mailing list