module-go-requests

command module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 8 Imported by: 0

README

Requests ThingsDB Module (Go)

Request module written using the Go language. This module can be used to make HTTP(S) requests with ThingsDB.

Installation

Install the module by running the following command in the @thingsdb scope:

new_module('requests', 'github.com/thingsdb/module-go-requests');

Optionally, you can choose a specific version by adding a @ followed with the release tag. For example: @v0.1.3.

Configuration

This module does not require any config.

Exposed functions

Name Description
get Make a GET request.
post Make a POST request.
post_json Make a JSON POST request.
req Make a HTTP request.
get

Syntax: get(url, options)

Arguments
  • url: The URL to make the GET request to.
  • options: Thing with properties to add to the GET request.
Example:
requests.get("https://reqbin.com/echo").then(|res| {
    res;  // just return the response.
});
post

Syntax: post(url, body, options)

Arguments
  • url: The URL to make the POST request to.
  • body: Body to send with the request (as bytes).
  • options: Thing with properties to add to the POST request.

For an example, see post_json below.

post_json

Syntax: post_json(url, body, options)

Like post, except that the headers will be set to accept and send JSON data.

Arguments
  • url: The URL to make the POST request to.
  • body: Body to send with the request (as bytes).
  • options: Thing with properties to add to the POST request.
Example:
record = {
    Id: 78912,
    Customer: "Jason Sweet",
    Quantity: 1,
    Price: 18.00
};
requests.post_json("https://reqbin.com/echo/post/json", json_dump(record)).then(|res| {
    res = res.load();
    json_load(str(res.body));
});
req

Syntax: req(url, options)

A valid method is required.

Arguments
  • url: The URL for the request.
  • options: Thing with properties for the request. At least a method is required.

Properties

Option Type Description
method str Method to use. For example GET, POST, PUT, PATCH or DELETE.
url str URL to use with the request.
body bytes Body to send with the request.
headers list Headers to send with the request. Must be a list with [[Key, Value],..] tuples.
allow_redirects bool If true, 10 redirects are allowed.
params list URL Params to send with the request. Must be a list with [[Key, Value],..] tuples.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址