HTTP requests
You can use the http namespace of the Runnable API to make HTTP requests from your Runnable code. These methods are currently the only way to access the network from Runnable code. Arbitrary socket and network access is not currently possible.
For Rust, these methods are available under the http module, for example http::get(). For Swift, they are prefixed with Http, for example Suborbital.HttpGet() For TypeScript/AssemblyScript, they are prefixed with http, for example import { httpPost } from '@suborbital/suborbital'
The following namespace methods are available:

GET

Performs an HTTP GET request
Rust:
1
pub fn get(url: &str, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>
Copied!
AssemblyScript:
1
function httpGet(url: string, headers: Map<string, string> | null): ArrayBuffer
Copied!
Swift:
1
public func HttpGet(url: String) -> String
Copied!

POST

Performs an HTTP POST request:
Rust:
1
pub fn post(url: &str, body: Option<Vec<u8>>, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>
Copied!
AssemblyScript:
1
function httpPost(url: string, body: ArrayBuffer, headers: Map<string, string> | null): ArrayBuffer
Copied!
Swift:
1
public func HttpPost(url: String, body: String) -> String
Copied!

PATCH

Performs an HTTP PATCH request:
Rust:
1
pub fn patch(url: &str, body: Option<Vec<u8>>, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>
Copied!
AssemblyScript:
1
function httpPatch(url: string, body: ArrayBuffer, headers: Map<string, string> | null): ArrayBuffer
Copied!
Swift:
1
public func HttpPatch(url: String, body: String) -> String
Copied!

DELETE

Performs an HTTP DELETE request:
Rust:
1
pub fn delete(url: &str, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>
Copied!
AssemblyScript:
1
function httpDelete(url: string, headers: Map<string, string> | null): ArrayBuffer
Copied!
Swift:
1
public func HttpDelete(url: String) -> String
Copied!
Swift does not yet support passing headers to a request.
Last modified 10d ago
Export as PDF
Copy link