Permalink
Browse files

Example for LibCurl::HTTP subroutines

  • Loading branch information...
CurtTilmes committed May 12, 2017
1 parent 2852659 commit cc1d02c87ec197d256f58988f867e8c6d3d3ce67
Showing with 19 additions and 0 deletions.
  1. +19 −0 eg/http.pl6
View
@@ -0,0 +1,19 @@
use v6;
use LibCurl::HTTP :subs;
# Just GET content (will return Failure on failure):
say get 'https://httpbin.org/get?foo=42&bar=x';
# GET and decode received data as JSON:
say jget('https://httpbin.org/get?foo=42&bar=x')<args><foo>;
# POST content (query args are OK; pass form as named args)
say post 'https://httpbin.org/post?foo=42&bar=x', :some<form>, :42args;
# And if you need headers, pass them inside a positional Hash:
say post 'https://httpbin.org/post?foo=42&bar=x', %(:Some<Custom-Header>),
:some<form>, :42args;
# Same POST as above + decode response as JSON
say jpost('https://httpbin.org/post', :some<form-arg>)<form><some>;

0 comments on commit cc1d02c

Please sign in to comment.