1JSON::RPC::Legacy::ServUesre:r:CCGoIn(t3r)ibuted Perl DoJcSuOmNe:n:tRaPtCi:o:nLegacy::Server::CGI(3)
2
3
4

NAME

6       JSON::RPC::Legacy::Server::CGI - JSON-RPC sever for CGI
7

SYNOPSIS

9        # CGI version
10        #--------------------------
11        # In your CGI script
12        use JSON::RPC::Legacy::Server::CGI;
13
14        my $server = JSON::RPC::Legacy::Server::CGI->new;
15
16        $server->dispatch('MyApp')->handle();
17
18        # or  an array ref setting
19
20        $server->dispatch( [qw/MyApp MyApp::Subclass/] )->handle();
21
22        # or a hash ref setting
23
24        $server->dispatch( {'/jsonrpc/API' => 'MyApp'} )->handle();
25
26
27        #--------------------------
28        # In your application class
29        package MyApp;
30
31        use base qw(JSON::RPC::Legacy::Procedure); # Perl 5.6 or more than
32
33        sub echo : Public {    # new version style. called by clients
34            # first argument is JSON::RPC::Legacy::Server object.
35            return $_[1];
36        }
37
38        sub sum : Public(a:num, b:num) { # sets value into object member a, b.
39            my ($s, $obj) = @_;
40            # return a scalar value or a hashref or an arryaref.
41            return $obj->{a} + $obj->{b};
42        }
43
44        sub a_private_method : Private {
45            # ... can't be called by client
46        }
47
48        sub sum_old_style {  # old version style. taken as Public
49            my ($s, @arg) = @_;
50           return $arg[0] + $arg[1];
51        }
52

DESCRIPTION

54       Gets a client request.
55
56       Parses its JSON data.
57
58       Passes the server object and the object decoded from the JSON data to
59       your procedure (method).
60
61       Takes your returned value (scalar or arrayref or hashref).
62
63       Sends a response.
64
65       Well, you write your procedure code only.
66

METHODS

68       They are inherited from the JSON::RPC::Legacy::Server methods
69       basically.  The below methods are implemented in
70       JSON::RPC::Legacy::Server::CGI.
71
72       new Creates new JSON::RPC::Legacy::Server::CGI object.
73
74       retrieve_json_from_post
75           retrieves a JSON request from the body in POST method.
76
77       retrieve_json_from_get
78           In the protocol v1.1, 'GET' request method is also allowable.  it
79           retrieves a JSON request from the query string in GET method.
80
81       response
82           returns a response JSON data to a client.
83
84       cgi returns the CGI object.
85

SEE ALSO

87       JSON::RPC::Legacy::Server,
88
89       JSON::RPC::Legacy::Procedure,
90
91       JSON,
92
93       <http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html>,
94
95       <http://json-rpc.org/wiki/specification>,
96

AUTHOR

98       Makamaka Hannyaharamitu, <makamaka[at]cpan.org>
99
101       Copyright 2007-2008 by Makamaka Hannyaharamitu
102
103       This library is free software; you can redistribute it and/or modify it
104       under the same terms as Perl itself.
105
106
107
108perl v5.32.0                      2020-07-28 JSON::RPC::Legacy::Server::CGI(3)
Impressum