diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2018-05-08 11:00:56 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2018-05-08 11:00:56 -0300 |
commit | 8ada19b8f3ac4cc2654d03025664582166151d14 (patch) | |
tree | 2ef7d49f4c84036c35d59fbbed42bf03fa055eeb | |
parent | 9670fb210c6a0fa2003d6cf0c12fc2166fc5e602 (diff) | |
download | perl6-matrix-client-8ada19b8f3ac4cc2654d03025664582166151d14.tar.gz |
Little cleanup for post methods
-rw-r--r-- | lib/Matrix/Client/Requester.pm6 | 6 |
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) { |