Pyro

A dynamically-typed, garbage-collected scripting language.

Version 0.19.2

Examples


Simple GET request

Make a simple GET request:

import std::curl;

let response = curl::GET("http://example.com/");

GET request with parameters

Make a GET request with a URL-encoded query string:

import std::curl;

let response = curl::Request()
    :url("http://example.com/")
    :param("foo", 123)
    :param("bar", 456)
    :GET();

Simple POST request

Make a simple POST request:

import std::curl;

let response = curl::POST("http://example.com/", "body");

POST request with parameters

Make a POST request with an application/x-www-form-urlencoded body:

import std::curl;

let response = curl::Request()
    :url("http://example.com/")
    :param("foo", 123)
    :param("bar", 456)
    :POST();

POST request with a JSON body

Make a POST request with a JSON body:

import std::curl;

let response = curl::Request()
    :url("http://example.com/")
    :header("Content-Type: application/json")
    :body(`{"foo": 123, "bar": 456}`)
    :POST();