| Author |
Message |
|
| rsaccon |
Posted: Fri Aug 11, 2006 9:15 pm |
|
|
|
User
Joined: 09 Aug 2006
Posts: 144
|
I realized that I still do not understand every bit of the functional
concepts used for the JSON RPC Handlers.
I want to access to the Arg (from the Yaws HTTP request) from within
my JSON RPC Handler. But how do I pass that Arg to tha handler ?
To make my question clear, let's take the code below (copy pasted form
the yaws website). I simply want to pass to "counter" the Argument
"A". How can I do that ?
regards
Roberto
<erl module=sample_mod>
out(A) ->
Peer = if
tuple(A#arg.clisock),
element(1, A#arg.clisock) == sslsocket ->
ssl:peername(A#arg.clisock);
true ->
inet:peername(A#arg.clisock)
end,
{ok,{IP,_}} = Peer,
A2=A#arg{state = [{ip, IP}]},
yaws_rpc:handler_session(A2, {sample_mod, counter}).
counter([{ip, IP}] = _State, {call, test1, Value} = _Request, Session) ->
io:format("Request = ~p~n", [_Request]),
IPStr = io_lib:format("Client ip is ~p~n" , [ IP ]),
OldSession = io_lib:format("Request is: ~p~nOld session value "
"is ~p~n", [ _Request, Session ]),
case Session of
undefined -> % create new session
NewSession = 0;
10 -> % reset session after reaching 10
NewSession = undefined;
N ->
NewSession = N + 1
end,
NewVal = io_lib:format("New session value is ~p ~n", [ NewSession ]),
Str = lists:flatten([IPStr,OldSession,NewVal]),
{true, 0, NewSession, {response, Str }}.
</erl>
--
Roberto Saccon
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Gaspar |
Posted: Sat Aug 12, 2006 9:09 am |
|
|
|
User
Joined: 20 Jul 2006
Posts: 55
|
Roberto Saccon wrote:
> I realized that I still do not understand every bit of the functional
> concepts used for the JSON RPC Handlers.
>
> I want to access to the Arg (from the Yaws HTTP request) from within
> my JSON RPC Handler. But how do I pass that Arg to tha handler ?
>
only Arg#arg.state is passed to handler, so if you vant to pass query
variables to handler -- then you should do somethingn like this:
Vars = yaws_api:query_parse(A),
A2=A#arg{state = [{ip, IP}, {query_vars, Vars}]},
so everything which you want pass to handler shoudl be processed
before yaws_rpc:handler_session call and put into #arg.state
--
Gaspar Chilingarov
System Administrator,
Network security consulting
t +37493 419763 (mob)
i 63174784
e nm@web.am
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| rsaccon |
Posted: Sat Aug 12, 2006 3:42 pm |
|
|
|
User
Joined: 09 Aug 2006
Posts: 144
|
Aaah, of course ! thanks yery much !
On 8/12/06, Gaspar Chilingarov <nm@web.am> wrote:
> Roberto Saccon wrote:
> > I realized that I still do not understand every bit of the functional
> > concepts used for the JSON RPC Handlers.
> >
> > I want to access to the Arg (from the Yaws HTTP request) from within
> > my JSON RPC Handler. But how do I pass that Arg to tha handler ?
> >
>
> only Arg#arg.state is passed to handler, so if you vant to pass query
> variables to handler -- then you should do somethingn like this:
>
> Vars = yaws_api:query_parse(A),
> A2=A#arg{state = [{ip, IP}, {query_vars, Vars}]},
>
> so everything which you want pass to handler shoudl be processed
> before yaws_rpc:handler_session call and put into #arg.state
>
>
>
>
>
> --
> Gaspar Chilingarov
>
> System Administrator,
> Network security consulting
>
> t +37493 419763 (mob)
> i 63174784
> e nm@web.am
>
--
Roberto Saccon
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|