HTTP client
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.
- Rust
- AssemblyScript 🧪
- Swift 🧪
In Rust these methods are available under the http module:
# Use the "http" module
use suborbital::http;
# Invoke the "Get" method
http::get(…)
In TypeScript/AssemblyScript all methods are prefixed with http:
// Import then invoke "Get" method
import { httpGet } from '@suborbital/suborbital'
httpGet(…)
In Swift these methods are prefixed with Http:
// Invoke the "Get" method
Suborbital.HttpGet(…)
note
Swift does not yet support passing headers to a request.
The following namespace methods are available:
GET​
Performs an HTTP GET request:
- Rust
- AssemblyScript 🧪
- Swift 🧪
pub fn get(url: &str, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>
function httpGet(url: string, headers: Map<string, string> | null): ArrayBuffer
public func HttpGet(url: String) -> String
POST​
Performs an HTTP POST request:
- Rust
- AssemblyScript 🧪
- Swift 🧪
pub fn post(url: &str, body: Option<Vec<u8>>, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>
function httpPost(url: string, body: ArrayBuffer, headers: Map<string, string> | null): ArrayBuffer
public func HttpPost(url: String, body: String) -> String
PATCH​
Performs an HTTP PATCH request:
- Rust
- AssemblyScript 🧪
- Swift 🧪
pub fn patch(url: &str, body: Option<Vec<u8>>, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>
function httpPatch(url: string, body: ArrayBuffer, headers: Map<string, string> | null): ArrayBuffer
public func HttpPatch(url: String, body: String) -> String
DELETE​
Performs an HTTP DELETE request:
- Rust
- AssemblyScript 🧪
- Swift 🧪
pub fn delete(url: &str, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>
function httpDelete(url: string, headers: Map<string, string> | null): ArrayBuffer
public func HttpDelete(url: String) -> String