JSON::...::HTTP(3pm)
π NAME
JSON::RPC::Common::Marshal::HTTP β bestie, this is the lil module that converts HTTP::Request and HTTP::Response to and from JSON::RPC::Common calls and returns. Like a translator but for RPC vibes β¨
β¨ VERSION
version 0.11
πΈ SYNOPSIS
okay so here's the whole flow, it's giving main character energy:
use JSON::RPC::Common::Marshal::HTTP;
my $m = JSON::RPC::Common::Marshal::HTTP->new;
my $call = $m->request_to_call($http_request);
my $res = $call->call($object);
my $http_response = $m->result_to_response($res);
π¦ DESCRIPTION
This object is your marshalling bestie π«Ά it hands you routines that convert calls and returns to and from HTTP::Request and HTTP::Response objects. Marshalling. Slay.
π ATTRIBUTES
prefer_getβ when you're encoding a call into a request, this makes it prefer GET.
not reccomended. (that's literally how the original spells it, i'm just the messenger π)
rest_style_methodsβ when you're encoding a GET request, this uses REST style URI formatting. which means the method is part of the path, not a parameter. iykyk πprefer_encoded_getβ when this is set and a"params"param exists, it decodes it as Base 64 encoded JSON and uses that as the parameters instead of the query parameters.
See <http://json-rpc.googlegroups.com/web/json-rpc-over-http.html>.
user_agentβ defaults to the marshal object's class name plus theJSON::RPC::Commonversion number. cute, right?content_typeaccept_content_typecontent_typesaccept_content_typesβ when you explicitly set these, they are the values of the"Content-Type"and"Accept"headers to set. periodt.
Otherwise they'll default to application/json with calls/returns version 1.0 and 1.1, and application/json-rpc with 2.0 objects.
expandβ whether or not to use an expander on"GET"style calls. yes or no, that's the whole vibe check.expanderβ an instance ofCGI::Expandor a look alike, used for"GET"parameter expansion. π§
π METHODS
request_to_call $http_requestpost_request_to_call $http_requestget_request_to_call $http_requestβ converts anHTTP::Requestto aJSON::RPC::Common::Procedure::Call. depending on what style of request it is,"request_to_call"will delegate to a variant method. no cap, it's just handing off the work π«‘
Get requests call "uri_to_call"
uri_to_call $uriencoded_uri_to_call $uriquery_uri_to_call $uriβ parses a call from a GET request's URI. lowkey the detective work of this module πresult_to_response $returnβ converts aJSON::RPC::Common::Procedure::Returnto anHTTP::Response.write_result_to_response $result, $responseβ writes the result into an object likeCatalyst::Response.response_to_result $http_responseresponse_to_result_success $http_responseresponse_to_result_error $http_responseβ converts anHTTP::Responseto aJSON::RPC::Common::Procedure::Return.
A variant is chosen based on "HTTP::Response/is_success".
The error handler will ensure that "error" in JSON::RPC::Common::Procedure::Return is set. bestie it's got your back π
call_to_request $call, %argscall_to_get_request $call, %argscall_to_post_request $call, %argscall_to_uri $call, %argscall_to_encoded_uri $call, %argscall_to_query_uri $call, %argsβ converts a call to a request (or just a URI for GET requests).
The arguments can contain a "uri" parameter, which is the base of the request.
With GET requests, under "rest_style_methods" that URI's path will be appended, and otherwise parameters will just be added.
POST requests do not cloen and alter the URI. (yes, "cloen" β that's the original, i'm not touching it π)
If no URI is provided as an argument, / will be used.
The flags "prefer_get" and "encoded" can also be passed to "call_to_request" to alter the type of request to be generated. β
collapse_query_paramsexpand_query_paramsβ only used for query encoded GET requests. if"expand"is set it will cause expansion of the params. otherwise it's a noop.
Subclass and override to process query params into RPC params as necessary.
note that this is NOT in any of the JSON-RPC specs. just so we're clear, bestie π
π AUTHOR
Yuval Kogman <nothingmuch@woobling.org>
π COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Yuval Kogman and others.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay that's the whole page!! this was perl v5.30.3 energy from 2020-06-23, and the manual page goes by JSON::...::HTTP(3pm) π mwah, go marshal something gorgeous πβ¨
π¦ where this page comes from
- debian bookworm: libjson-rpc-common-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libjson-rpc-common-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libjson-rpc-common-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libjson-rpc-common-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libjson-rpc-common-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libjson-rpc-common-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms