Yes, That's how I recall it too, though my before_ works in either case, so
I can't be sure.

Certainly the documentation (http://www.chicagoboss.org/api-controller.html)
seems to support your recollection:

If an action takes three arguments, then the function before_/3 in your
controller will be passed:

   - the action name as a string
   - the request method as an atom
   - the list of URL tokens

before_/3 should return one of:

etc


Cheers,

g




On 23 October 2014 04:20, Jitin Luthra <[email protected]> wrote:

> Hi !
> Thanks a lot for your reply.
>
> However, I think I was asking something a little different. I can
> understand how you describe the use of before_ function for authorization.
> My situation is that I have a controller where some actions require
> authorization while others do not.
> I think that the docs and the tutorial suggest that the way this gets
> handled is that only those actions that have* three arguments* - such as
> hello('GET',[],_) invoke the before_ function, while the actions with *two
> arguments* such as hello('GET',[]) do not call the before_ function. Does
> it not work like that?
>
> Look at this code:
>
> before_(_,_,_)->
>        {redirect,"http://yahoo.com"}.
>
> hello('GET',[])->
>  {output,"ok"}.
>
>
> I have a hello('GET',[]) with *two arguments. *Why should what I write in
> before_ even matter at all (since hello has only two arguments and not
> three)?
>
> And yet when I open the hello action it redirects me to yahoo.com. This
> is what confuses me. Is this supposed to happen like this?
>
> Thanks,
> Jitin
>
> On Wednesday, 22 October 2014 20:44:11 UTC+5:30, can2nac wrote:
>>
>> http://www.chicagoboss.org/api-controller.html , see Authorization
>> section
>>
>> before_(_,_,_)->
>>  case some_func_result(Req) of
>>    false -> {redirect,"http://yahoo.com"};
>>    {true,Data} -> {ok, Data}
>>  end.
>>
>> hi('GET',[], Data)->
>> {output,"ok"}.
>>
>> hello('GET',[], _)->
>> {output,"ok"}.
>>
>> the code is from the top of my head, so please, doublecheck.
>>
>> On Wednesday, October 22, 2014 2:36:56 PM UTC+4, 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/3c4672ce-a610-4222-b43c-3b1f8d112dac%40googlegroups.com
> <https://groups.google.com/d/msgid/chicagoboss/3c4672ce-a610-4222-b43c-3b1f8d112dac%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAKF5fiAbWfXzUPqZu9nSXX6Lt%2B4sJZ0YRRZqzYKRw3TTFdN3GA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to