Examples
- Simple GET request
- GET request with parameters
- Simple POST request
- POST request with parameters
- POST request with a JSON body
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();