aboutsummaryrefslogtreecommitdiff
path: root/lib/Matrix/Client
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2018-05-08 11:00:56 -0300
committerMatias Linares <matiaslina@openmailbox.org>2018-05-08 11:00:56 -0300
commit8ada19b8f3ac4cc2654d03025664582166151d14 (patch)
tree2ef7d49f4c84036c35d59fbbed42bf03fa055eeb /lib/Matrix/Client
parent9670fb210c6a0fa2003d6cf0c12fc2166fc5e602 (diff)
downloadperl6-matrix-client-8ada19b8f3ac4cc2654d03025664582166151d14.tar.gz
Little cleanup for post methods
Diffstat (limited to 'lib/Matrix/Client')
-rw-r--r--lib/Matrix/Client/Requester.pm66
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Matrix/Client/Requester.pm6 b/lib/Matrix/Client/Requester.pm6
index 0bb7e3a..9cabf9c 100644
--- a/lib/Matrix/Client/Requester.pm6
+++ b/lib/Matrix/Client/Requester.pm6
@@ -40,7 +40,8 @@ method base-url(Bool :$media? = False --> Str) {
}
multi method post(Str $path, Str $json, :$media = False) {
- my $req = HTTP::Request.new(POST => $.base-url(:$media) ~ $path ~ "?access_token=$!access-token",
+ my $url = $.base-url(:$media) ~ $path ~ "?access_token=$!access-token";
+ my $req = HTTP::Request.new(POST => $url,
Content-Type => 'application/json');
$req.add-content($json);
@@ -48,7 +49,8 @@ multi method post(Str $path, Str $json, :$media = False) {
}
multi method post(Str $path, :$media = False, *%params) {
- self.post($path, :$media, to-json(%params))
+ my $json = to-json(%params);
+ nextwith($path, $json, :$media)
}
method post-bin(Str $path, Buf $buf, :$content-type) {