Perl HTTP 守护进程服务器 - 读取 POST JSON 正文
Perl HTTP Daemon Server- Reading POST JSON body
我在使用 HTTP::Daemon to create a http server for my API. With the help of following example and doc,我能够创建一个基本的 HTTP 服务器。
但是,我的 API 应该接受 JSON 作为对服务器的 post 请求的主体。所以,我需要阅读 JSON 以便我可以处理它。我知道,如何读取 url param $r->uri->query_form();
有没有办法读取POSTJSON?
use JSON;
use Data::Dumper;
my $json = decode_json($r->content);
print Dumper $json;
我在使用 HTTP::Daemon to create a http server for my API. With the help of following example and doc,我能够创建一个基本的 HTTP 服务器。
但是,我的 API 应该接受 JSON 作为对服务器的 post 请求的主体。所以,我需要阅读 JSON 以便我可以处理它。我知道,如何读取 url param $r->uri->query_form();
有没有办法读取POSTJSON?
use JSON;
use Data::Dumper;
my $json = decode_json($r->content);
print Dumper $json;