Thanks for the replies.
So I guess the before_ function does apply to all actions in a given 
controller - regardless of if they have two or three arguments.
The solutions suggested work well but right now I am just going to create a 
separate controller for public actions without the before_ function.

Also the method Nick suggested is great - it separates the 'policies' from 
the controllers - so you don't have to define authorization in the 
controller itself but can control which controllers / actions will need 
authorization from the config file.

Thanks,
Jitin

On Friday, 24 October 2014 02:14:14 UTC+5:30, Nick Garanko wrote:
>
> Hey Guys,
>
> Not sure if my message is related to topic :)
>
> If you need to apply some code before controller is executed - make use of 
> filters 
> <https://github.com/ChicagoBoss/ChicagoBoss/blob/master/README_FILTERS.md>
>  
>
> Here's example 'login_required_filter 
> <https://github.com/ngaranko/r2d2/blob/master/src/lib/login_required_filter.erl>'
>  
> and it's configuration 
> <https://github.com/ngaranko/r2d2/blob/master/boss.config#L114-L123> I 
> wrote for one of my toy projects.
>
> Kind regards,
> -Nick
>
> On Wednesday, October 22, 2014 12:36:56 PM UTC+2, Jitin Luthra wrote:
>>
>> Hi,
>>
>> I am using a before_ function in my controller and have some actions in 
>> my controller with only two arguments. 
>> However, the before_ function gets called even for those actions with two 
>> arguments. 
>> Did it not used to be that the before_ code would only get called for 
>> actions having 3 arguments?
>>
>> Sample code:
>>
>> -module(test_hello_controller,[Req]).
>> -compile(export_all).
>>
>> before_(_,_,_)->
>> {redirect,"http://yahoo.com"}.
>>
>> hi('GET',[])->
>> {output,"ok"}.
>>
>> When trying to load the 'hi' action, I get redirected to yahoo.com .
>>
>> Thanks,
>> Jitin
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/chicagoboss/d197637b-5650-4d54-8868-9c7ce5e256da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to