1JSON::RPC::Legacy::ServUesre:r:ACpoancthrei2b(u3t)ed PerJlSODNo:c:uRmPeCn:t:aLteigoancy::Server::Apache2(3)
2
3
4
6 JSON::RPC::Legacy::Server::Apache2 - JSON-RPC sever for mod_perl2
7
9 # In apache conf
10
11 PerlRequire /your/path/start.pl
12 PerlModule MyApp
13
14 <Location /jsonrpc/API>
15 SetHandler perl-script
16 PerlResponseHandler JSON::RPC::Legacy::Server::Apache
17 PerlSetVar dispatch "MyApp"
18 PerlSetVar return_die_message 0
19 </Location>
20
21 #--------------------------
22 # In your application class
23 package MyApp;
24
25 use base qw(JSON::RPC::Legacy::Procedure); # Perl 5.6 or more than
26
27 sub echo : Public { # new version style. called by clients
28 # first argument is JSON::RPC::Legacy::Server object.
29 return $_[1];
30 }
31
32 sub sum : Public(a:num, b:num) { # sets value into object member a, b.
33 my ($s, $obj) = @_;
34 # return a scalar value or a hashref or an arryaref.
35 return $obj->{a} + $obj->{b};
36 }
37
38 sub a_private_method : Private {
39 # ... can't be called by client
40 }
41
42 sub sum_old_style { # old version style. taken as Public
43 my ($s, @arg) = @_;
44 return $arg[0] + $arg[1];
45 }
46
48 Gets a client request.
49
50 Parses its JSON data.
51
52 Passes the server object and the object decoded from the JSON data to
53 your procedure (method).
54
55 Takes your returned value (scalar or arrayref or hashref).
56
57 Sends a response.
58
59 Well, you write your procedure code only.
60
62 They are inherited from the JSON::RPC::Legacy::Server methods
63 basically. The below methods are implemented in
64 JSON::RPC::Legacy::Server::Apache2.
65
66 new Creates new JSON::RPC::Legacy::Server::Apache2 object.
67
68 handle
69 Runs server object and returns a response.
70
71 retrieve_json_from_post
72 retrieves a JSON request from the body in POST method.
73
74 retrieve_json_from_get
75 In the protocol v1.1, 'GET' request method is also allowable. it
76 retrieves a JSON request from the query string in GET method.
77
78 response
79 returns a response JSON data to a client.
80
82 JSON::RPC::Legacy::Server,
83
84 JSON::RPC::Legacy::Procedure,
85
86 JSON,
87
88 <http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html>,
89
90 <http://json-rpc.org/wiki/specification>,
91
93 Makamaka Hannyaharamitu, <makamaka[at]cpan.org>
94
96 Copyright 2007-2008 by Makamaka Hannyaharamitu
97
98 This library is free software; you can redistribute it and/or modify it
99 under the same terms as Perl itself.
100
101
102
103perl v5.30.0 2019-07-J2S6ON::RPC::Legacy::Server::Apache2(3)