Frontie...esponder(3)
π Frontie...esponder(3) β like, the whole page, bestie
okay so real talk: this is a page from the User Contributed Perl Documentation, and it's about Frontier::Responder. Yes the title is doing that truncated thing. Yes we're still gonna read it together. π«Ά
β¨ NAME β¨
Frontier::Responder β create XML-RPC listeners for normal CGI processes. that's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
like, here's the whole thing, character for character, no notes:
use Frontier::Responder;
my $res = Frontier::Responder->new( methods => {
add => sub{ $_[0] + $_[1] },
cat => sub{ $_[0] . $_[1] },
},
);
print $res->answer;
see how add and cat are justβ¦ hash keys pointing at subs? that's the whole trick. iconic. β¨
π¦ DESCRIPTION π¦
so, when do you reach for Frontier::Responder? whenever you need to create an XML-RPC listener using a standard CGI interface. that's the assignment. π
and here's a thing people forget: to be effective, a script using this class will often have to be put in a directory from which a web server is authorized to execute CGI programs. like, the web server has to actually be allowed to run your CGI in that directory, or none of this works. the more you know. π
a listener built with this library is implementing the API of a particular XML-RPC application. and every remote procedure listed in the API of your user-defined application corresponds to a hash key that's defined in the new method of a Frontier::Responder object. this is exactly the way Frontier::Daemon works as well β same energy, different wrapper. π
then, to process the request and get the response, you need the answer method. its return value is XML ready for printing. boom. done. β
π§ for the XML-RPC newbies (brief protocol moment)
for those new to XML-RPC, here's a brief description of this protocol, bestie, because i've got you:
XML-RPC is a way to execute functions on a different machine. both the client's request and the listener's response are wrapped up in XML and sent over HTTP. and because the XML-RPC conversation is in XML, the implementation languages of the server (here called a listener) and the client can be totally different. which is genuinely a powerful and simple way to have very different platforms work together without acrimony. no drama, just XML. ποΈ
implicit in the use of XML-RPC is a contract or API that an XML-RPC listener implements and an XML-RPC client calls. the API needs to list not only the various procedures that can be called, but also the XML-RPC datatypes expected for input and output. remember that although Perl is permissive about datatyping, other languages are not. π
unfortunately, the XML-RPC spec doesn't say how to document the API. π
it is recommended that the author of a Perl XML-RPC listener should at least use POD to explain the API. that allows for the programmatic generation of a clean web page. so likeβ¦ write your docs, babe. π
π METHODS π
π new( OPTIONS )
this is the class constructor. as is traditional, it returns a blessed reference to a Frontier::Responder object. it expects arguments to be given like a hash (Perl's named parameter mechanism β you know the one).
to be effective, populate the methods parameter with a hashref that has API procedure names as keys and subroutine references as values. see the SYNOPSIS for a sample usage. π
π answer()
in order to parse the request and execute the procedure, this method must be called. it returns an XML string that contains the procedure's response. in a typical CGI program, this string will simply be printed to STDOUT. that's the whole flow. π
π₯ SEE ALSO π₯
π AUTHOR π
- Ken MacLeod
<ken@bitsko.slc.ut.us>wrote the underlying RPC library. π - Joe Johnston
<jjohn@cs.umb.edu>wrote an adaptation of theFrontier::Daemonclass to create this CGI XML-RPC listener class. π
and that's the tea. π this page is from perl v5.32.1, dated 2023-10-24 β go forth and listen to some XML-RPC, bestie. π β¨
π¦ where this page comes from
- epel 9: perl-Frontier-RPC-doc 0.07b4p1-48.el9 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms