From 8ada19b8f3ac4cc2654d03025664582166151d14 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Tue, 8 May 2018 11:00:56 -0300 Subject: Little cleanup for post methods --- lib/Matrix/Client/Requester.pm6 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') 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) { -- cgit v1.2.3-54-g00ecf